我想在google +上分享我的內容。這裏是教程中,我下面未能通過Android與Google +分享
這是給我的問題的一部分。
Intent shareIntent = ShareCompat.IntentBuilder.from(MyActivity.this)
.setType("text/plain")
.setText("Welcome to the Google+ platform. https://developers.google.com/+")
.getIntent()
.setPackage("myPakageName");
這裏是日誌
09-09 08:05:10.510: W/dalvikvm(716): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
09-09 08:05:10.601: E/AndroidRuntime(716): FATAL EXCEPTION: main
09-09 08:05:10.601: E/AndroidRuntime(716): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=text/plain flg=0x80000 pkg=(myPakageName) (has extras) }
09-09 08:05:10.601: E/AndroidRuntime(716): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
09-09 08:05:10.601: E/AndroidRuntime(716): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
09-09 08:05:10.601: E/AndroidRuntime(716): at android.app.Activity.startActivityForResult(Activity.java:3190)
09-09 08:05:10.601: E/AndroidRuntime(716): at android.app.Activity.startActivity(Activity.java:3297)
09-09 08:05:10.601: E/AndroidRuntime(716): at com.trib.jax.mbhealth.MainMenu.shareGoogle(MainMenu.java:275)
09-09 08:05:10.601: E/AndroidRuntime(716): at com.trib.jax.mbhealth.MainMenu.access$5(MainMenu.java:267)
09-09 08:05:10.601: E/AndroidRuntime(716): at com.trib.jax.mbhealth.MainMenu$13.onClick(MainMenu.java:308)
09-09 08:05:10.601: E/AndroidRuntime(716): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
09-09 08:05:10.601: E/AndroidRuntime(716): at android.os.Handler.dispatchMessage(Handler.java:99)
09-09 08:05:10.601: E/AndroidRuntime(716): at android.os.Looper.loop(Looper.java:137)
09-09 08:05:10.601: E/AndroidRuntime(716): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-09 08:05:10.601: E/AndroidRuntime(716): at java.lang.reflect.Method.invokeNative(Native Method)
09-09 08:05:10.601: E/AndroidRuntime(716): at java.lang.reflect.Method.invoke(Method.java:511)
09-09 08:05:10.601: E/AndroidRuntime(716): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-09 08:
您可以調用.getIntent()。setPackage(「com.google.android.apps.plus」),並且如果安裝了Google+應用程序,它將起作用。在意圖上設置目標不取決於Google Play服務。 https://play.google.com/store/apps/details?id=com.google.android.apps.plus&hl=en –