Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无意图接收装置城市飞艇_Android_Android Intent_Push Notification_Urbanairship.com - Fatal编程技术网

Android 无意图接收装置城市飞艇

Android 无意图接收装置城市飞艇,android,android-intent,push-notification,urbanairship.com,Android,Android Intent,Push Notification,Urbanairship.com,我确实收到推送消息,但每当我在通知栏中单击它们时,就会出现此日志,通知消失 <category android:name="com.test.push" /> </intent-filter> </receiver> <service android:name="com.urbanairship.push.PushService" android:label="Push Notification Service"

我确实收到推送消息,但每当我在通知栏中单击它们时,就会出现此日志,通知消失

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>
这是我的logcat输出:

 05-31 16:49:47.165: D/Test - UALib(20523): No intent receiver set, not sending ACTION_NOTIFICATION_OPENED
        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>
以下是我的清单结构:

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>
这是我的IntentReceiver.java:

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>
public class IntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context aContext, Intent aIntent) {
String action = aIntent.getAction();

if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
    logPushExtras(aIntent);
} else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
    logPushExtras(aIntent);

    Intent launch = new Intent(Intent.ACTION_MAIN);
    launch.setClass(UAirship.shared().getApplicationContext(),
            MainActivity.class);

    launch.putExtra("push_message",
            aIntent.getStringExtra(PushManager.EXTRA_ALERT));
    launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    UAirship.shared().getApplicationContext().startActivity(launch);
} else if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
    Logger.info("device registrated, APID="
            + aIntent.getStringExtra(PushManager.EXTRA_APID)
            + ", valid="
            + aIntent.getBooleanExtra(
                    PushManager.EXTRA_REGISTRATION_VALID, false));
}
}

private void logPushExtras(Intent intent) {
Set<String> keys = intent.getExtras().keySet();
for (String key : keys) {

    List<String> ignoredKeys = (List<String>) Arrays.asList(
            "collapse_key", "from", PushManager.EXTRA_NOTIFICATION_ID,
            PushManager.EXTRA_PUSH_ID, PushManager.EXTRA_ALERT);
    if (ignoredKeys.contains(key)) {
        continue;
    }
}
}
}
公共类IntentReceiver扩展了BroadcastReceiver{
@凌驾
接收时公共无效(上下文、文本、意图){
String action=ainent.getAction();
if(action.equals(PushManager.action\u PUSH\u RECEIVED)){
后勤支援(安顿);
}else if(action.equals(PushManager.action\u通知\u打开)){
后勤支援(安顿);
意图启动=新意图(Intent.ACTION\u MAIN);
launch.setClass(UAirship.shared().getApplicationContext(),
主要活动(课堂);
launch.putExtra(“推送消息”,
ainnt.getStringExtra(PushManager.EXTRA_ALERT));
启动.setFlags(意图.FLAG\u活动\u新任务);
UAirship.shared().getApplicationContext().startActivity(启动);
}else if(action.equals(PushManager.action\u REGISTRATION\u FINISHED)){
Logger.info(“设备注册,APID=”
+ainent.getStringExtra(PushManager.EXTRA\u APID)
+,有效='
+ainent.getBooleanExtra(
PushManager.EXTRA_注册(有效,错误));
}
}
专用无效logPushExtras(意向){
Set keys=intent.getExtras().keySet();
用于(字符串键:键){
List ignoredKeys=(List)Arrays.asList(
“折叠密钥”、“发件人”、PushManager.EXTRA\u通知\u ID、,
PushManager.EXTRA\u PUSH\u ID,PushManager.EXTRA\u ALERT);
if(ignoredKeys.contains(键)){
继续;
}
}
}
}

问题是,我的
MyApplication.java
文件中缺少以下行:

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>
    PushManager.shared().setIntentReceiver(IntentReceiver.class);

其余的都是对的。它现在工作得很好。

我没有在清单文件中指定应用程序的
android:name
属性-

        <category android:name="com.test.push" />
    </intent-filter>
</receiver>

<service
    android:name="com.urbanairship.push.PushService"
    android:label="Push Notification Service" />
<service
    android:name="com.urbanairship.push.PushWorkerService"
    android:label="Push Notification Worker Service" />
<service
    android:name="com.urbanairship.analytics.EventService"
    android:label="Event Service" />

<provider
    android:name="com.urbanairship.UrbanAirshipProvider"
    android:authorities="com.test.push.urbanairship.provider"
    android:exported="false"
    android:multiprocess="true" />

<activity
    android:name="com.test.push.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.test.push.SettingsActivity"
    android:label="@string/title_activity_settings" />
<activity
    android:name="com.test.push.ChooseClass"
    android:label="@string/app_name" />
</application>
<application
  android:allowBackup="true"
  android:icon="@drawable/app_icon"
  android:label="@string/app_name"
  android:theme="@style/AppTheme"
  android:allowClearUserData="true"
  android:enabled="true" 
  android:name=".MyMainApplication">

  <activity>
  Some Activity
  </activity>

</application>

一些活动

您将此语句保存在java文件中的何处?实际上,我将此语句保存在onCreate()中,但不起作用。