I have some problem. I write app for android
package com.google.android.gms.samples.plus;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.plus.Plus;
import com.google.android.gms.plus.PlusShare;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
/**
* Example of sharing with Google+ through the ACTION_SEND intent.
*/
public class ShareActivity extends Activity implements View.OnClickListener,
DialogInterface.OnCancelListener {
protected static final String TAG = "ShareActivity";
private static final String STATE_SHARING = "state_sharing";
private static final int DIALOG_GET_GOOGLE_PLAY_SERVICES = 1;
private static final int REQUEST_CODE_INTERACTIVE_POST = 1;
private static final int REQUEST_CODE_GET_GOOGLE_PLAY_SERVICES = 2;
/** The button should say "View item" in English. */
private static final String LABEL_VIEW_ITEM = "VIEW_ITEM";
private EditText mEditSendText;
@SuppressLint("NewApi") @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share_activity);
Button sendButton = (Button) findViewById(R.id.send_interactive_button);
sendButton.setOnClickListener(this);
mEditSendText = (EditText) findViewById(R.id.share_prefill_edit);
int available = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (available != ConnectionResult.SUCCESS) {
showDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
//getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
public void onClickShare(View v) {
Intent photoPicker = new Intent(Intent.ACTION_PICK);
photoPicker.setType("image/*");
startActivityForResult(photoPicker, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
int REQ_SELECT_PHOTO = 1;
if(requestCode == REQ_SELECT_PHOTO ) {
if(resultCode == RESULT_OK) {
Uri selectedImage = data.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);
int REQ_START_SHARE = 2;
startActivityForResult(share.getIntent(), REQ_START_SHARE );
}
}
}
@Override
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
onClickShare(v);
}}
I compile and run it. Where I press button (R.id.send_interactive_button) and choose image for share program return exception on startActivityForResult(share.getIntent(), REQ_START_SHARE ); line
11-01 21:00:36.844: W/IInputConnectionWrapper(5942): showStatusIcon on inactive InputConnection
11-01 21:00:54.073: W/dalvikvm(5942): threadid=1: thread exiting with uncaught exception (group=0x41d28438)
11-01 21:00:54.163: E/AndroidRuntime(5942): FATAL EXCEPTION: main
11-01 21:00:54.163: E/AndroidRuntime(5942): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/96881 }} to activity {com.google.android.gms.samples.plus/com.google.android.gms.samples.plus.ShareActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=image/png flg=0x80001 pkg=com.google.android.apps.plus (has clip) (has extras) }
11-01 21:00:54.163: E/AndroidRuntime(5942): at android.app.ActivityThread.deliverResults(ActivityThread.java:3195)
11-01 21:00:54.163: E/AndroidRuntime(5942): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3238)
11-01 21:00:54.163: E/AndroidRuntime(5942): at android.app.ActivityThread.access$1100(ActivityThread.java:138)
11-01 21:00:54.163: E/AndroidRuntime(5942): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1252)
11-01 21:00:54.163: E/AndroidRuntime(5942): at android.os.Handler.dispatchMessage(Handler.java:99)
11-01 21:00:54.163: E/AndroidRuntime(5942): at android.os.Looper.loop(Looper.java:137)
please help me, where I write wrong code, and how fix it? Thank you.
0 comments:
Post a Comment