2013-10-13 67 views
0

我尝试在Google +上共享帖子,但获得此异常。创建异常的活动是为ExampleActivity,这是它的代码:尝试解决ActivityNotFoundException

public class ExampleActivity extends Activity implements OnClickListener, 
      ConnectionCallbacks, OnConnectionFailedListener { 
     private static final String TAG = "ExampleActivity"; 
     private static final int REQUEST_CODE_RESOLVE_ERR = 9000; 

     private ProgressDialog mConnectionProgressDialog; 
     private PlusClient mPlusClient; 
     private ConnectionResult mConnectionResult; 

     @Override//onCreate 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_example); 
      mPlusClient = new PlusClient.Builder(this, this, this) 
        .setVisibleActivities("http://schemas.google.com/AddActivity","http://schemas.google.com/BuyActivity") 
        .build(); 
      // Progress bar to be displayed if the connection failure is not resolved. 
      mConnectionProgressDialog = new ProgressDialog(this); 


    mConnectionProgressDialog.setMessage("Signing in..."); 
     Button shareButton = (Button) findViewById(R.id.share_button); 
     shareButton.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       // Launch the Google+ share dialog with attribution to your app. 
       Intent shareIntent = new PlusShare.Builder() 
        .setType("text/plain") 
        .setText("Welcome to 

the Google+ platform.") 
         .setContentUrl(Uri.parse("https://developers.google.com/+/")) 
         .getIntent(); 

        startActivityForResult(shareIntent, 0); 
       } 
      }); 

     } 

     @Override//onStart 
     protected void onStart() { 
      super.onStart(); 
      mPlusClient.connect(); 
     } 

     @Override//onStop 
     protected void onStop() { 
      super.onStop(); 
      mPlusClient.disconnect(); 
     } 

     @Override// onConnectionFailed 
     public void onConnectionFailed(ConnectionResult result) { 
      if (mConnectionProgressDialog.isShowing()) { 
      // The user clicked the sign-in button already. Start to resolve 
      // connection errors. Wait until onConnected() to dismiss the 
      // connection dialog. 
      if (result.hasResolution()) { 
       try { 
         result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR); 
       } catch (SendIntentException e) { 
         mPlusClient.connect(); 
       } 
      } 
      } 
      // Save the result and resolve the connection failure upon a user click. 
      mConnectionResult = result; 
     } 

     @Override //onActivityResult 
     protected void onActivityResult(int requestCode, int responseCode, Intent intent) { 
      if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) { 
       mConnectionResult = null; 
       mPlusClient.connect(); 
      } 
     } 

    // @Override 
    // public void onConnected(Bundle connectionHint) { 
    //  String accountName = mPlusClient.getAccountName(); 
    //  Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show(); 
    // } 

     @Override //onDisconnected 
     public void onDisconnected() { 
       String accountName = mPlusClient.getAccountName(); 
       Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show(); 
     } 

     @Override//onConnected 
     public void onConnected() { 
      // TODO Auto-generated method stub 

     } 

     @Override 
     public void onClick(View arg0) { 


     } 
    } 

这是AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="com.example.applicazionescienza" 
     android:versionCode="1" 
     android:versionName="1.0" > 

     <uses-sdk 
      android:minSdkVersion="11" 
      android:targetSdkVersion="17" /> 

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

     <application 
      android:allowBackup="true" 
      android:icon="@drawable/ic_launcher" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme" > 
      <activity 
       android:name="com.example.applicazionescienza.Menu" 
       android:label="@string/app_name" 
       android:launchMode="singleInstance" > 
       <intent-filter> 
        <action android:name="android.intent.action.MAIN" /> 

        <category android:name="android.intent.category.LAUNCHER" /> 
       </intent-filter> 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.Informazioni" 
       android:label="@string/title_activity_informazioni" > 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.Regolamento" 
       android:label="@string/title_activity_regolamento" > 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.Gioca" 
       android:label="@string/title_activity_gioca" > 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.Livello" 
       android:label="@string/title_activity_livello" > 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.Punteggio" 
       android:label="@string/title_activity_punteggio" > 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.TwitterActivity" 
       android:label="@string/title_activity_twitter" 
       android:launchMode="singleInstance" > 
       <intent-filter> 
        <action android:name="android.intent.action.VIEW" /> 

        <category android:name="android.intent.category.DEFAULT" /> 
        <category android:name="android.intent.category.BROWSABLE" /> 

        <data 
         android:host="casa" 
         android:scheme="app" /> 
       </intent-filter> 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.FacebookActivity" 
       android:label="@string/title_activity_facebook" > 
      </activity> 
      <activity 
       android:name="com.example.applicazionescienza.ExampleActivity" 
       android:label="@string/title_activity_example" > 
       <intent-filter> 
        <action android:name="android.intent.action.SEND" /> 
        <category android:name="android.intent.category.DEFAULT" /> 
       </intent-filter> 
      </activity> 
     </application> 
    </manifest> 

除外说:无活动处理意向(ACT = android.intent .action.SEND .... 有人能帮帮我吗?

+0

请张贴格式正确的代码。善待我们​​,我们在这里帮助你。 –

+0

请发送例外的完整文本 –

+0

您是在设备还是仿真器中检查此代码?请检查这个帖子:http://stackoverflow.com/questions/11517563/no-activity-found-to-handle-intent-while-emailing-data –

回答

0

尝试和clean项目,从设备卸载应用程序,并重新安装。

相关问题