0

着信に応答するブロードキャスト レシーバーを追加しました。以下は、ブロードキャスト レシーバーの onreceive メソッドのコードです。

Bundle extras=intent.getExtras();
        if(extras!=null)
        {
            String state=extras.getString(TelephonyManager.EXTRA_STATE);
            System.out.println(state);
            if(state.equals(TelephonyManager.CALL_STATE_RINGING))
            {
                String phoneno=extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                Toast.makeText(context, "proper", Toast.LENGTH_SHORT).show();
                System.out.println("no is "+phoneno);

                NotificationManager nm=(NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
                Notification nt=new Notification(R.drawable.ic_launcher, "You got call", System.currentTimeMillis()+2000);
                String title="You got call";
                String text="The call you got was from "+phoneno;
                Intent ii=new Intent("");
                //ii.setData(Uri.parse("http://www.google.com"));
                PendingIntent pi=PendingIntent.getActivity(context, 1, ii, 0);
                nt.setLatestEventInfo(context, title, text, pi);
                nm.notify(5, nt);
                Toast.makeText(context, "proper", Toast.LENGTH_SHORT).show();





            }

        }

ただし、ddms から呼び出しを送信すると、通知は表示されません。ログ メッセージが追加された場合は詳細に表示されます。これが発生している理由を親切に更新してください。ありがとうテジンダー

4

1 に答える 1