0

ブロードキャストレシーバーをAndroidマニフェストファイルに登録する際に問題が発生しました

ユーザーが通知をクリックしてマップアクティビティに移動するかどうかを確認するBroadcastReceiverを作成しました。問題は、クリックすると通知が消えてしまうことです。これは、broadcasrReceiverが正常に登録されていないことが原因だと思います。EclipseIDEを使用しています。

以下は私のAndroidマニフェストXmlです

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

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

<uses-sdk android:minSdkVersion="9" />

<application
    android:name="com.example.fyp_api_8_team.MyGobalClass"
    android:icon="@drawable/shazam"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-library android:name="com.google.android.maps" />

    <activity
        android:name="com.example.fyp_api_8_team.SplashScreen"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Login_Form"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Register_form" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Register_form"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Register_form" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Forget_form"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Forget_form" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Create_Meeting_Form"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Create_Meeting_form" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Create_Team_Form"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Create_Team_Form" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Map_Location"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Map_Location" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Main" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Register_Form"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Register_Form" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity android:name="com.example.fyp_api_8_team.MainPreferenceActivity" >
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Team_Members"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN.Create_Team_Form..Team_Members" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.fyp_api_8_team.Show_Map"
        android:label="@string/title_activity_show__map" >
    </activity>

    <service android:name="com.example.fyp_api_8_team.Services.ScheduleService" />
    <service android:name="com.example.fyp_api_8_team.Services.NotifyService" />
    <receiver android:name="com.example.fyp_api_8_team.MyBroadcastReceiver" android:enabled="true"></receiver>
</application>

これはMyBroadcastReceiverクラスです

package com.example.fyp_api_8_team;
 import com.example.fyp_api_8_team.R;
 import com.example.fyp_api_8_team_AlertMap.Show_Map;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;     
 import android.os.Vibrator;
 import android.util.Log;


    public class MyBroadcastReceiver extends BroadcastReceiver {
private NotificationManager mNotificationManager;
public static int SIMPLE_NOTFICATION_ID;
public static String title, Message;
public static int Meetingid, pos;

@Override
public void onReceive(Context context, Intent intent) {

    mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notifyDetails = new Notification(
            R.drawable.stat_notify_more, "You Alarm is here",
            System.currentTimeMillis());

    // take you to the Map class by notification click
    Intent notificationIntent = new Intent(context, Show_Map.class);

    PendingIntent myIntent = PendingIntent.getActivity(context, 0,
            notificationIntent, 0);

    // Sets the Map class for the particular notification of event
    Show_Map.position = pos;
    notifyDetails.setLatestEventInfo(context, title,
            "Click on me to view you Meeting Location", myIntent);

    notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL;
    notifyDetails.flags |= Notification.DEFAULT_SOUND;
    mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);

    Log.i(getClass().getSimpleName(), "Sucessfully Notification Clicked");

    // Vibrate the mobile phone
    Vibrator vibrator = (Vibrator) context
            .getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(2000);
}

}

4

1 に答える 1

1

次のように宣言する必要があります。

<receiver android:name="com.example.fyp_api_8_team.MyBroadcastReceiver">
            <intent-filter>
                <action android:name="**your_action_name**" />
            </intent-filter>
        </receiver>
于 2013-01-15T16:32:41.520 に答える