2016-07-14 25 views
1

からロケーションアップデートを受け取るためにbroadcast receiverを作成しました。私の放送受信機では、私は位置座標を表示するための通知を設定しました。当初、すべてが正常に機能していましたが、今は通知を受け取ることができません。通知が表示されない

ここ
07-14 14:55:01.730 1129-1129/? I/dalvikvm: DexOpt: access denied from Landroid/support/v4/app/NotificationCompatKitKat; to field Landroid/app/Notification;.actions 
07-14 14:55:05.274 510-525/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x56f982f8 
07-14 14:55:05.411 510-745/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x597bfe08 
07-14 14:55:05.580 804-815/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x576cca28 
07-14 14:55:07.493 26570-28863/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x51612400 
07-14 14:55:07.499 26570-28864/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x516297e8 
07-14 14:55:07.510 26570-28863/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x5160d788 
07-14 14:55:07.518 26570-26582/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x51681818 
07-14 14:55:07.538 26570-26581/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x5165bd50 
07-14 14:55:07.554 26570-28864/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x51617630 
07-14 14:55:07.557 510-521/? D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x597bfe08 
07-14 14:55:07.648 1179-1179/com.svtech.thirdeye.thirdeye I/dalvikvm: Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza 
07-14 14:55:07.648 1179-1179/com.svtech.thirdeye.thirdeye W/dalvikvm: VFY: unable to resolve virtual method 242: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder; 
07-14 14:55:07.648 1179-1179/com.svtech.thirdeye.thirdeye I/dalvikvm: DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil; to field Landroid/app/Notification;.extras 
07-14 14:55:07.722 1179-1179/com.svtech.thirdeye.thirdeye I/dalvikvm: Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method gsi.a 
07-14 14:55:07.722 1179-1179/com.svtech.thirdeye.thirdeye W/dalvikvm: VFY: unable to resolve virtual method 527: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder; 
07-14 14:55:07.722 1179-1179/com.svtech.thirdeye.thirdeye I/dalvikvm: DexOpt: access denied from Lgsi; to field Landroid/app/Notification;.extras 
07-14 14:55:07.950 1179-1179/com.svtech.thirdeye.thirdeye I/dalvikvm: Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method kk.a 
07-14 14:55:07.951 1179-1179/com.svtech.thirdeye.thirdeye W/dalvikvm: VFY: unable to resolve virtual method 1338: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder; 
07-14 14:55:07.951 1179-1179/com.svtech.thirdeye.thirdeye I/dalvikvm: DexOpt: access denied from Lkk; to field Landroid/app/Notification;.extras 

は私BroadCast Receiverクラスである:ここで

は私のlogcatある

public class LocationHandlerReceiver extends BroadcastReceiver { 

    public static final int NOTIFICATION_ID = 1; 

    public LocationHandlerReceiver() { 
    } 

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

     if (LocationResult.hasResult(intent)) { 
      LocationResult locationResult = LocationResult.extractResult(intent); 
      Location mLocation = locationResult.getLastLocation(); 
      Log.i("Intent Service", mLocation.toString()); 

      setupNotification(context, mLocation); 
     } 
    } 


    //Setup Notification 
    private void setupNotification(Context context, Location location) { 

     PendingIntent contentIntent = PendingIntent.getActivity(context, 0, 
       new Intent(context, MainActivity.class), 0); 

     NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) 
       .setSmallIcon(R.drawable.location_start_notification) 
       .setContentTitle(context.getResources().getString(R.string.location_notification)) 
       .setContentText("Lat: " + location.getLatitude() + ", Long: " + location.getLongitude()); 
     mBuilder.setContentIntent(contentIntent); 
     mBuilder.setAutoCancel(true); 
     mBuilder.setLocalOnly(false); 
     mBuilder.setOngoing(true); 
     NotificationManager mNotificationManager = 
       (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
     mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); 

    } 
} 

PS:私は私の最初のいくつかの実行ではアンドロイド4.2.2、API 17でアプリをテストしています通知が表示されました。

編集:ここに私のManifestファイルです:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.svtech.thirdeye.thirdeye"> 

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

<application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     android:name="android.support.multidex.MultiDexApplication"> 

     .......... 

     <receiver 
      android:name=".BroadcastReceivers.LocationHandlerReceiver" 
      android:exported="false"> 
      <intent-filter> 
       <action android:name="android.intent.action.BOOT_COMPLETED" /> 
       <action android:name="thirdeye.LOCATION_RECEIVED" /> 

       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </receiver> 
    </application> 

誰も私が問題を特定するのに役立ちますが????

+0

あなたのマニフェストで ''としてあなたLocationHandlerReceiverが含まれました? – Marat

+0

なぜあなたは ''として受信者を設定しましたか? – Marat

+0

通知をタップしたときにユーザーがアプリを開くことができるようにするには...しかし、それは私の問題とは無関係です。私もそれを取り除こうとした。それは私の間違いだった... @マラート –

答えて

1

まず第一には、マニフェストファイルにこの権限を追加:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 

を次に<category android:name="android.intent.category.LAUNCHER"/>行を削除して、このようにそれを作る:

<receiver 
    android:name=".BroadcastReceivers.LocationHandlerReceiver" 
    android:exported="false"> 
    <intent-filter> 
     <action android:name="android.intent.action.BOOT_COMPLETED" /> 
     <action android:name="thirdeye.LOCATION_RECEIVED" /> 
    </intent-filter> 
</receiver> 
関連する問題