Muhammad Umar
Muhammad Umar

Reputation: 11782

Failing to share on google+ with android

I am trying to share my content on google+. Here is the tutorial I am following

Google+ Tutorial

This the part that is giving me problem.

Intent shareIntent = ShareCompat.IntentBuilder.from(MyActivity.this)
          .setType("text/plain")
          .setText("Welcome to the Google+ platform. https://developers.google.com/+")
          .getIntent()
          .setPackage("myPakageName");

Here is the log

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:

Upvotes: 0

Views: 2545

Answers (2)

Snicolas
Snicolas

Reputation: 38168

You package statement is certainly wrong, that should be left blank to share with all sharing apps, or targeted toward google plus only (as explained by @Morrison Chang).

Generally speaking, it's better not to target intents to a specific app, so users can decide which one to choose according to their preferences. That's one of the strength of android.

Upvotes: 0

Morrison Chang
Morrison Chang

Reputation: 12121

In the tutorial you need to have setPackage as the package name for the Google Plus app / service

.getIntent().setPackage("com.google.android.apps.plus")

Which means that this can only be run on device/emulator with the Google Play Services library. However that same page states that

Note: The Google+ platform for Android will soon be available in the coming weeks — this documentation gives you a quick overview of what to expect.

Since it doesn't appear to be released, I'm not sure what you've done to get this far.

Upvotes: 2

Related Questions