Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在我的应用程序中调用另一个应用程序时,我的应用程序关闭_Android - Fatal编程技术网

Android 在我的应用程序中调用另一个应用程序时,我的应用程序关闭

Android 在我的应用程序中调用另一个应用程序时,我的应用程序关闭,android,Android,我尝试调用应用程序中的另一个应用程序来共享数据。但是当另一个应用程序打开时,我的应用程序突然崩溃,没有任何错误或警告。我怎样才能解决这个问题 我的代码是 Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("image/jpeg"); boolean facebookAppFound = false; List<ResolveInfo> resInfo = getPackageMan

我尝试调用应用程序中的另一个应用程序来共享数据。但是当另一个应用程序打开时,我的应用程序突然崩溃,没有任何错误或警告。我怎样才能解决这个问题

我的代码是

Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/jpeg");
boolean facebookAppFound = false;
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
if (!resInfo.isEmpty()) {
    for (ResolveInfo info : resInfo) {
        if (info.activityInfo.packageName.toLowerCase().contains(nameApp)  || info.activityInfo.name.toLowerCase() .contains(nameApp)) {
            share.putExtra(Intent.EXTRA_SUBJECT, "subject");
            share.putExtra(Intent.EXTRA_TEXT, "My Info");
            share.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(imagePath))); 
            share.setPackage(info.activityInfo.packageName);
            facebookAppFound = true;
            break;
        }
    }
    if (!facebookAppFound) {
        String sharerUrl = "https://www.facebook.com/mypage/mypage.php?u=" + Uri.fromFile(new File(imagePath));
        share = new Intent(Intent.ACTION_VIEW,
        Uri.parse(sharerUrl));
    }
} 
else {
    if (!facebookAppFound) {
        String sharerUrl = "https://www.facebook.com/shwetech/shwetech.php?u=" + Uri.fromFile(new File(imagePath));
        share = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
    } 
}
startActivity(Intent.createChooser(share, "Select")); 

.....
Intent share=newintent(android.content.Intent.ACTION\u SEND);
share.setType(“图像/jpeg”);
布尔facebookAppFound=false;
List resInfo=getPackageManager().queryInputActivities(共享,0);
如果(!resInfo.isEmpty()){
对于(ResolveInfo:resInfo){
if(info.activityInfo.packageName.toLowerCase().contains(nameApp)| info.activityInfo.name.toLowerCase().contains(nameApp)){
share.putExtra(Intent.EXTRA_SUBJECT,“SUBJECT”);
share.putExtra(Intent.EXTRA_文本,“我的信息”);
share.putExtra(Intent.EXTRA_流,Uri.fromFile(新文件(imagePath));
share.setPackage(info.activityInfo.packageName);
facebookAppFound=true;
打破
}
}
如果(!facebookAppFound){
字符串sharerUrl=”https://www.facebook.com/mypage/mypage.php?u=“+Uri.fromFile(新文件(imagePath));
共享=新意图(Intent.ACTION\u视图,
parse(sharerUrl));
}
} 
否则{
如果(!facebookAppFound){
字符串sharerUrl=”https://www.facebook.com/shwetech/shwetech.php?u=“+Uri.fromFile(新文件(imagePath));
share=newintent(Intent.ACTION_视图,Uri.parse(sharerUrl));
} 
}
startActivity(Intent.createChooser(共享,“选择”));
.....

完成此代码后
startActivity(Intent.createChooser(共享,“选择”)我的应用程序已关闭。

显示您的代码。并在打开另一个应用程序时详细解释共享一些代码或检查是否调用finish…logcat输出或某种调试输出将很有帮助。@Veeru,logcat没有警告,没有错误