文字列をインテント エクストラとして渡しています。次のメソッドには、インテントを介して渡したい情報を含むパラメーターが渡されます。「mc」と「title」の値がトーストにあるはずのとおりであることがわかります。
private void addProximityAlert(int id, Double latitude, Double longitude, String title, String mc) {
Intent intent = new Intent(PROX_ALERT_INTENT);
intent.putExtra("id", id);
intent.putExtra("mc", mc);
intent.putExtra("gl", latitude);
intent.putExtra("title", title);
PendingIntent proximityIntent = PendingIntent.getBroadcast(Map.this, id, intent, 0);
lm.addProximityAlert( latitude, longitude, POINT_RADIUS, PROX_ALERT_EXPIRATION, proximityIntent );
Toast.makeText(getApplicationContext(),"INPAMAP "+intent.getStringExtra("title")+intent.getStringExtra("mc"),Toast.LENGTH_SHORT).show();
}
次のクラスでは、何をしようとしても、「mc」がその値を保持するだけで、他の変数は常に null です。次のアクティビティは次のとおりです。
@Override
public void onReceive(Context context, Intent intent) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, Map.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
Notification notification = createNotification();
//Here I can see title is null and mc is what it should be
Toast.makeText(context,"IN PA "+intent.getStringExtra("title")+intent.getStringExtra("mc") ,Toast.LENGTH_SHORT).show();
バンドルを使用してみましたが、これは機能しませんでした。mc と title が両方とも文字列であるのに、なぜ mc だけが渡されるのか完全にわかりません。mc または title のいずれかのみを渡そうとしましたが、mc のみが null ではありません。それらが addproximityAlert メソッドに渡される順序と、エクストラとして追加される順序を変更しようとしましたが、オプションがありません。SOに来る前にこれらの問題を自分で理解できるように、Eclipseで適切にデバッグする方法を実際に知りたいのですが、多くの時間的プレッシャーにさらされています。
私の問題が何であるかを理解する方法についてアドバイスをいただければ幸いです。ありがとうございます。