2012-01-15 12 views
1

暗黙のインテントコールが失敗しているのは少し混乱します。 (ダッシュボード)の活動(ワークアウト)と呼ばれる暗黙のインテントを持つアクティビティの開始に失敗しました

Intent intent = new Intent(Intent.ACTION_VIEW); 
    intent.setDataAndType(WorkoutProvider.CONTENT_URI, "vnd.android.cursor.dir/vnd.chrisolsen.crossfit.workout"); 
    startActivity(intent); 

活動を呼び出す

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://org.chrisolsen.crossfit.providers.WorkoutProvider/workouts typ=vnd.android.cursor.dir/vnd.chrisolsen.crossfit.workout } 

AndroidManifest

<activity android:name=".activities.WorkoutsActivity" 
     android:label="@string/title_workouts" > 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <data android:mimeType="vnd.android.cursor.dir/vnd.chrisolsen.crossfit.workout"/> 
     </intent-filter> 
    </activity> 

    <provider 
     android:name=".providers.WorkoutProvider" 
     android:authorities="org.chrisolsen.crossfit.providers.WorkoutProvider" />  

:意図を起動しようとすると、私は次のエラーを取得しておきます。それはここにはありません

これは単純なはずですが、私はなぜ活動がないと言われているのか混乱しています。

アイデア?

+0

あなたがマニフェストにあなたのプロバイダWorkoutProviderを宣言したことがありますか? – Bourbon

+0

はい、あります。私は質問を更新しました。インテントを呼び出すにはプロバイダが必要ですが? – chris

答えて

4

暗黙の意図で開始するためには、活動はまた

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

を宣言する必要があり、あなたがstartActivity代わりのsendBroadcastを使用していることを確認してください。これらの方法には違いがあります。アクティビティのインテントフィルタによってブロードキャストは受信されません。そのためにはBroadcastReceiverを使用する必要があります。

Note that, although the Intent class is used for sending and receiving these broadcasts, the Intent broadcast mechanism here is completely separate from Intents that are used to start Activities with Context.startActivity(). There is no way for a BroadcastReceiver to see or capture Intents used with startActivity(); likewise, when you broadcast an Intent, you will never find or start an Activity. These two operations are semantically very different: starting an Activity with an Intent is a foreground operation that modifies what the user is currently interacting with; broadcasting an Intent is a background operation that the user is not normally aware of.

出典:http://developer.android.com/reference/android/content/BroadcastReceiver.html

Android docs: sendBroadcast

Android docs: startActivity