Wie starte ich eine Aktivität, wenn der Benutzer auf eine Benachrichtigung klickt?

Ich versuche, einen Code, den ich in einem Tutorial gefunden habe, für meinen eigenen Gebrauch zu konvertieren. Der Code hat ursprünglich die Systemkontaktliste gestartet, als der Benutzer auf eine von meiner App generierte Benachrichtigung geklickt hat. Ich versuche eineActivity von mir selbst, anstatt die Kontaktliste zu starten, aber es funktioniert nicht. Genauer gesagt passiert nichts. Es ist kein Fehler, und meineActivity lädt auch nicht. Das Benachrichtigungsfenster verschwindet nach dem Klicken und das OriginalActivity ist noch sichtbar.

Hier ist mein Code:

<code>public class MyBroadcastReceiver extends BroadcastReceiver {
    private NotificationManager mNotificationManager;
    private int SIMPLE_NOTFICATION_ID;

    public void onReceive(Context context, Intent intent){
        Bundle extras = intent.getExtras();

        String deal = (String) extras.get("Deal");
        String title = "Deal found at " + (String) extras.get("LocationName");

        mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notifyDetails = new Notification(R.drawable.icon, title,System.currentTimeMillis());

        Class ourClass;
        try {
            ourClass = Class.forName("com.kjdv.gpsVegas.ViewTarget");
            Intent startMyActivity = new Intent(context, ourClass);

            PendingIntent myIntent = PendingIntent.getActivity(context, 0,startMyActivity, 0);
            notifyDetails.setLatestEventInfo(context, title, deal, myIntent);
            notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL;
            notifyDetails.flags |= Notification.DEFAULT_SOUND;
            mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
        }
        catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
</code>

Dies ist mein Eintrag in derAndroidManifext.xml Datei...

<code>  <activity android:name=".ViewTarget" android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.kjdv.gpsVegas.ViewTarget" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
   </activity>
</code>

Und das ist meinActivity dass ich starten möchte ...

<code>public class ViewTarget extends ListActivity {
    public ListAdapter getListAdapter() {
        return super.getListAdapter();
    }

    public ListView getListView() {
        return super.getListView();
    }

    public void setListAdapter(ListAdapter adapter) {
        super.setListAdapter(adapter);
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.locations);
        Log.v("db", "Inside ViewTarget");
    }
}
</code>

Antworten auf die Frage(6)

Ihre Antwort auf die Frage