0

サウンドを再生し、通知マネージャーを使用してAndroidフォンのバックライトを点滅させようとしています。私は次のコードを使用しました。必要なすべての権限はマニフェストファイルにあります。しかし、なぜこれがエミュレーターまたはデバイス(htc wildfire)で通知を出さないのかわかりません。実行可能な解決策をご存知の場合はお知らせください

XYNotificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        int NOTFICATION_ID = 1331;
        Notification notifyDetails = new Notification();
        notifyDetails.icon = R.drawable.icon12;
        notifyDetails.tickerText = "Message Received!!!";
        notifyDetails.when = System.currentTimeMillis();

        notifyDetails.vibrate = new long[] {0,1000,1000,1000,1000,1000,1000,1000}; //vibrate;

        Intent notifyIntent = new Intent(this, XYReceiverAppActivity.class);

        PendingIntent pIntent = PendingIntent.getActivity(this, 0,notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);

        CharSequence contentTitle = "XYs Notification";
        CharSequence contentText = "Get back to XY HOME screen by clicking me";


        notifyDetails.setLatestEventInfo(this, contentTitle, contentText, pIntent);

        Uri xysound = Uri.parse("android.resource://" + getPackageName() +"/"+ "soundxy");

        notifyDetails.ledARGB = Color.BLUE;
        notifyDetails.ledOnMS = 10000;
        notifyDetails.ledOffMS = 1000;
        notifyDetails.flags |= Notification.FLAG_SHOW_LIGHTS;
        notifyDetails.sound =  xysound;



        XYNotificationManager.notify(NOTFICATION_ID, notifyDetails);

デバイスが振動しておらず、音による警告もありません。LEDライトは同じです。通知を送信するにはどうすればよいですか?

4

1 に答える 1

1

これが私のプログラムの1つで使用しているコードです、それは常に機能しました...

        int icon = R.drawable.alerte;
        CharSequence tickerText = getString(R.string.lieuproche);
        long when = System.currentTimeMillis();
        Notification notification = new Notification(icon, tickerText, when);
        Intent intent = new Intent(getApplicationContext(),
                ActivityToLaunch.class);

        notification.setLatestEventInfo(
                MainActivity.this,
                "title",
                "action", PendingIntent.getActivity(
                        this.getBaseContext(), 0, intent,
                        PendingIntent.FLAG_CANCEL_CURRENT));
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        notification.defaults |= Notification.DEFAULT_SOUND;
        notification.defaults |= Notification.DEFAULT_LIGHTS;
        notificationManager.notify(0, notification);
于 2011-09-28T15:33:22.840 に答える