Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActivityNotFoundException In Google Plus

My Application Want to share Image on Google Plus And I have read About Google Plus And API shows that we can post media File using PlusShare.Builder. And I have Also Searched In stackoverflow but ditn't Get any Proper Answer. And I have Tried with These Code is :

case R.id.Share:
         if (mPlusClient.isConnected()) {
         Intent shareIntent = new PlusShare.Builder(this,mPlusClient)
         .setType("image/*")
         .setText("Risk Score")
         .addStream(Uri.fromFile(new File(Path)))
         .getIntent();
         startActivityForResult(shareIntent, REQ_START_SHARE);
         }

        break;

And

  case R.id.Share:

Intent shareIntent = ShareCompat.IntentBuilder.from(PlusActivity.this)
   .setText("This site has lots of great information about Android! http://www.android.com")
.setType("image/*").addStream(Uri.fromFile(new File(Path)))
.getIntent().setPackage("com.google.android.apps.plus");             
 startActivityForResult(shareIntent, REQ_START_SHARE);
        break;

And

 case R.id.Share:

         Intent shareIntent = new PlusShare.Builder(this,mPlusClient)
         .setType("image/*")
         .setText("Risk Score")
         .addStream(Uri.fromFile(new File(Path)))
         .getIntent();
         startActivityForResult(shareIntent, REQ_START_SHARE);

        break;

And Every Time I am Getting Same Problem.

12-05 12:19:57.316: E/AndroidRuntime(4688): FATAL EXCEPTION: main
12-05 12:19:57.316: E/AndroidRuntime(4688): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=image/* flg=0x80000 pkg=com.google.android.apps.plus (has extras) }
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1518)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1390)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.app.Activity.startActivityForResult(Activity.java:3204)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at com.winit.android.riskfactor.PlusActivity.onClick(PlusActivity.java:133)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.view.View.performClick(View.java:3517)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.view.View$PerformClick.run(View.java:14155)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.os.Handler.handleCallback(Handler.java:605)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.os.Looper.loop(Looper.java:154)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at android.app.ActivityThread.main(ActivityThread.java:4624)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at java.lang.reflect.Method.invokeNative(Native Method)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at java.lang.reflect.Method.invoke(Method.java:511)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
12-05 12:19:57.316: E/AndroidRuntime(4688):     at dalvik.system.NativeStart.main(Native Method)

And I have read these Question Also

sending-json-data-to-google-plus

android-google-plush-intregation-in-my-android-app-gives-android-content-activit

sending-json-data-to-google-plus

failing-to-share-on-google-with-android

no-activity-found-to-handle-intent-causes-fc

like image 852
Cropper Avatar asked Dec 05 '13 06:12

Cropper


2 Answers

Google+ does not have an independent write API available to general developers - the only way to post to Google+ via an app is to open the Google+ app (preferably using the Intent returned by PlusShare.Builder) So If Google plus is not present then it will give ActivityNotFoundException.

like image 192
Ari Avatar answered Sep 17 '22 12:09

Ari


Try this link and follow the step by step procedure. I have followed the same and worked for me. Another thing is clean your project or restart eclipse IDE or Install Google+ app (apk) on your device or emulator.
You can also take a look at my answer posted here the step by step Procedure to install Google+ App on Emulator.
Hope it will solve your problem...

Edited:
Try this code on your btn_share

Intent shareIntent = ShareCompat.IntentBuilder.from(ExampleActivity.this)
          .setType("image/*")
          .setText("Welcome to the Google+ platform. https://developers.google.com/+")
          .getIntent()
          .setPackage("com.google.android.apps.plus");//this line is important you should set your package like in this code.

      startActivity(shareIntent);
like image 39
Zubair Ahmed Avatar answered Sep 18 '22 12:09

Zubair Ahmed