我的项目的构建路径上有一个库(jar).项目使用以下意图访问jar中的MainActivity:
final Intent it = new Intent();
it.setClassName("com.example.lib", "com.example.lib.MainActivity");
startActivity(it);
Run Code Online (Sandbox Code Playgroud)
它曾经工作了一段时间,但突然开始得到'ActivityNotFoundException:没有找到活动来处理Intent',我能够解决它.但是现在我遇到了'java.lang.SecurityException:Permission Denial:start Intent'.
我已经尝试了所有关于stackoverflow的建议(检查清单文件中的重复项;将lib:exported ="true"添加到lib清单; Eclipse> Project> Clean;添加/修改'intent-filter'标签;等等).我甚至尝试重新编写项目的清单,但没有去任何地方.
这是logcat输出:
11-07 06:20:52.176: E/AndroidRuntime(4626): FATAL EXCEPTION: main
11-07 06:20:52.176: E/AndroidRuntime(4626): java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.example.lib/.MainActivity } from ProcessRecord{40dd3778 4626:com.example.project/u0a10046} (pid=4626, uid=10046) not exported from uid 10047
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.os.Parcel.readException(Parcel.java:1425)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.os.Parcel.readException(Parcel.java:1379)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1885)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1412)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Activity.startActivityForResult(Activity.java:3370)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Activity.startActivityForResult(Activity.java:3331)
11-07 06:20:52.176: E/AndroidRuntime(4626): at …Run Code Online (Sandbox Code Playgroud) 目标:使用文件资源管理器选择文件并上传到 Firebase 存储。
包:file_picker:^2.1.4
问题:引发错误:“无效参数(路径):不得为空”。
文件资源管理器打开正常,我可以选择一个文件。但是,选择文件后没有任何反应。下面是我迄今为止尝试过的代码:
FilePickerResult result;
File uploadfile;
try{
result = await FilePicker.platform.pickFiles(type: FileType.custom,
allowedExtensions: ['jpg', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt'],
);
} catch(e) {
print(e);
}
if(result != null) {
try{
uploadfile = File(result.files.single.path);
String filename = basename(uploadfile.path);
StorageReference storageRef = FirebaseStorage.instance.ref().child('$path$filename');
final StorageUploadTask uploadTask = storageRef.putFile(uploadfile);
final StorageTaskSnapshot downloadUrl = (await uploadTask.onComplete);
if (downloadUrl.error == null){
final String attchurl = (await downloadUrl.ref.getDownloadURL());
}
} catch(e) {
print(e);
}
Run Code Online (Sandbox Code Playgroud)
我确信代码会在以下位置引发错误:uploadfile = File(result.files.single.path);
我尝试了多个博客中提供的各种建议。即使这里的解决方案没有帮助,我也遇到同样的错误。参见下面的代码: …
我已经尝试了stackoverflow提供的所有可能的解决方案.但是我仍然在logcat中遇到这个错误:
'活动com.xyz.MainActivity泄露了窗口com.android.internal.policy.impl.PhoneWindow $ DecorView {40d687c0 VE .... R ..... ID 0,0-772,268}最初添加在这里'
if (Var_place_holder.level == "one")
{
Var_place_holder.title=obj_itemDetails.getTitle();
Var_place_holder.level="two";
Intent intent = getIntent();
dialog.dismiss();
finish();
startActivity(intent);}
if (Var_place_holder.level == "two")
{
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
String Category = Var_place_holder.title;
//String IMGURL = obj_itemDetails.getIcon();
String Desc = obj_itemDetails.getTitle();
alert.setTitle("Detail:");
String Msg1 = "Category: " + Category;
String Msg2 = "Desc: " + Desc;
alert.setMessage(Msg1+"\n"+Msg2+"\n");
//alert.setMessage("Price: Rs." + Price);
alert.setPositiveButton("Add", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//**************************************
//Do …Run Code Online (Sandbox Code Playgroud) 我有一个工作的expandablelistview代码,它作为一个独立的工作正常.我有另一个用于滑动标签视图的工作代码,我单独编写.
这些都是在通过一些博客,android开发和stackoverflow问题后编写的.
当我尝试将可扩展的listview组合并放入其中一个片段时,我最终得到一个错误,我无法解决.
这是Fragment片段中的代码:
public class Fragment1 extends Fragment {
private static final String NAME = "NAME";
private static final String IS_EVEN = "IS_EVEN";
private ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
for (int i = 0; i < 10; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put(NAME, "Group " + i);
curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group …Run Code Online (Sandbox Code Playgroud)