我正在爲一家公司申請,我需要在Instagram上分享。Android Instagram分享例外
我使用的代碼是:
public void SharingToSocialMedia(String application) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "http://www.google.sk/");
boolean installed = checkAppInstall(application);
if (installed) {
intent.setPackage(application);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(),
"Nie je nainštalovaná aplikácia", Toast.LENGTH_LONG).show();
}
}
private boolean checkAppInstall(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
return false;
}
其中
application = "com.instagram.android"
的問題是,我收到此錯誤
05-07 16:48:50.728 6192-6192/eu.maweb.lodkanadeje.lodkanadeje E/AndroidRuntime: FATAL EXCEPTION: main
Process: eu.maweb.lodkanadeje.lodkanadeje, PID: 6192
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=text/plain flg=0x1 pkg=com.instagram.android clip={text/plain T:http://www.google.sk/} (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1854)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1544)
at android.app.Activity.startActivityForResult(Activity.java:4391)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:4335)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:4697)
at android.app.Activity.startActivity(Activity.java:4665)
at eu.maweb.lodkanadeje.lodkanadeje.MainActivity.SharingToSocialMedia(MainActivity.java:134)
at eu.maweb.lodkanadeje.lodkanadeje.MainActivity.onNavigationItemSelected(MainActivity.java:117)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:156)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:88)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:342)
at android.view.View.performClick(View.java:5646)
at android.view.View$PerformClick.run(View.java:22450)
at android.os.Handler.handleCallback(Handler.java:755)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
我使用Facebook的相同的代碼併爲Twitter和它完美的作品......所以有人可以幫助我這個異常?
UPDATE
這裏是清單文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.maweb.lodkanadeje.lodkanadeje">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/lodka"
android:label="Loďka Nádeje"
android:roundIcon="@mipmap/lodka"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<provider
android:authorities="com.facebook.app.FacebookContentProvider2295668910658614"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
<activity
android:configChanges="orientation|screenSize"
android:name=".MainActivity"
android:label="Loďka nádeje"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
的[安卓的Instagram]可能的複製(http://stackoverflow.com/questions/13177677/android-instagram) –
請參閱(文檔)[https://www.instagram.com/developer/mobile-sharing/android-intents/]查看應該包含哪些內容(快速提示:instagram是關於共享圖像的) – njzk2