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

  • onTouchEvent is getting executed when page is swiped using ViewPager and PassByValue
  • Android NDK timers
  • Disable multi finger touch in my app
  • Soft Keyboard Overlapping with EditText Field
  • SQLiteDatabase 'does not implement interface'
  • How using SQLiteOpenHelper with database on sd-card?
  •   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

    Related posts:

    Animated Icon for ActionItem
    Android device is not connected to USB for debugging (Android studio)
    Extract / distinguish ActivityAlias name from TargetActivity
    Using custom login button with Twitter Fabric?
    Different behavior of Calendar class in Java and Android
    What is exact meaning of “kitchen sink” in programming?
  • Extract bitmap from video in android
  • Set up a Stomp client in android with Spring framework in server side
  • Android. Custom Intent chooser
  • How can I tell if my Application is resumed from background?
  • Open a numeric keyboard without forcing the EditText to be numeric only
  • Two line text for MenuItem
  • 7 Solutions collect form web for “ActivityNotFoundException In Google Plus”

    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.

    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);
    

    Google+ require Google+ installed on the device. Added this code to catch exception.

    try {
        startActivityForResult(builder.getIntent(), 0);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(YourActivity.this, "You haven't installed google+ on your device", Toast.LENGTH_SHORT).show();
    }
    

    Yes you can share images on Google plus with PlusBuilder. Add the Google Play Services library as a reference in your project. This Method calls com.google.android.gms.plus.PlusShare$Builder class for sharing. If Google plus is not present then it will give ActivityNotFoundException.

    MainActivity.java

     import android.app.Activity;
     import android.content.ContentResolver;
     import android.content.Intent;
     import android.content.IntentSender.SendIntentException;
     import android.net.Uri;
     import android.os.Bundle;
     import android.view.Menu;
     import android.view.View;
     import android.view.View.OnClickListener;
     import android.widget.Button;
    
     import com.google.android.gms.common.ConnectionResult;
     import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
     import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
     import com.google.android.gms.plus.PlusClient;
     import com.google.android.gms.plus.PlusOneButton;
     import com.google.android.gms.plus.PlusShare;
    
     public class MainActivity extends Activity implements ConnectionCallbacks, OnConnectionFailedListener{
    
    
    
    
    private static final int PLUS_ONE_REQUEST_CODE = 0;
    private static final int REQ_SELECT_PHOTO = 1;
    private static final int REQ_START_SHARE = 2;
    private PlusClient mPlusClient;
    Button share;
    private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mPlusClient = new PlusClient.Builder(MainActivity.this, MainActivity.this, MainActivity.this)
        .build();
    
    
        share=(Button)findViewById(R.id.share);
        share.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent photoPicker = new Intent(Intent.ACTION_PICK);
                photoPicker.setType("image/*");
                startActivityForResult(photoPicker, REQ_SELECT_PHOTO);
            }
        });
    }
    
    
    
    @Override
    public void onConnectionFailed(ConnectionResult result) {
        // TODO Auto-generated method stub
        if (result.hasResolution()) {
            try {
                result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
            } catch (SendIntentException e) {
                mPlusClient.connect();
            }
    
        }
    }
    
    
    @Override
    public void onConnected(Bundle arg0) {
        // TODO Auto-generated method stub
    
    }
    
    
    @Override
    public void onDisconnected() {
        // TODO Auto-generated method stub
    
    }
    
    @Override
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
        if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
            mPlusClient.connect();
            return;
        }
        if(requestCode == REQ_SELECT_PHOTO) {
            if(responseCode == RESULT_OK) {
                Uri selectedImage = intent.getData();
                ContentResolver cr = this.getContentResolver();
                String mime = cr.getType(selectedImage);
    
                PlusShare.Builder share = new PlusShare.Builder(this);
                share.setText("hello everyone!");
                share.addStream(selectedImage);
                share.setType(mime);
                startActivityForResult(share.getIntent(), REQ_START_SHARE);
            }
        }
    }
    
    @Override
    protected void onResume() {
        super.onResume();        
        //  mPlusOneStandardButtonWithAnnotation.initialize( URL, PLUS_ONE_REQUEST_CODE);
    }
    
    @Override
    protected void onStart() {
        super.onStart();
        mPlusClient.connect();
    }
    @Override
    protected void onStop() {
        super.onStop();
        mPlusClient.disconnect();
    
    }
     }
    

    share is a button and galley will be opened on its click.

    Add following lines of code in AndroidManifest.xml under application tag

       <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    

    and the Internet permission:

    <uses-permission android:name="android.permission.INTERNET"/>
    

    This is a working example of Google Plus Sharing.

    Just perform a check if google services are available

            int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
            if (errorCode != ConnectionResult.SUCCESS) {
                GooglePlayServicesUtil.getErrorDialog(errorCode, this, 0).show();
            } else {
                // Do somethings
            }
    

    You need to import this package:

    import com.google.android.gms.common.GooglePlayServicesUtil;
    

    NOTE: Usually the emulator don’t have Google Play Services installed except if you has selected Google APIs instead of Android APIs for your emulated device but in this case you must check also if google account is available.

    This is related somehow to .settype().
    I had .setType("text/html") and was experiencing this error. But after I have changed it to .setType(“text/plain”) the problem was solved. I don’t know why, but the .settype() is the reason of this problem.

    for me I forgot to add setType("image/*")
    and now it works fine

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.