Adobe AIR 3.2 とネイティブ拡張機能を使用して、Android 用のアクション sctipt でアプリケーションを作成しています。私の仕事は、通知にネイティブ拡張をスローさせ、その通知をクリックできるようにし、バックグラウンドからアプリケーションを開く必要があることです。通知を実行するようにしましたが、クリックしてもアプリケーションを実行できません。どうすればそれができますか?私は何を間違えましたか?助けてください、ありがとう。
package com.company.extensions;
import java.util.HashMap;
import java.util.Map;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;
import android.util.Log;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
public class ToolsExtensionContext extends FREContext
{
public Vibrator vb = null;
@Override
public void dispose()
{
}
@Override
public Map<String, FREFunction> getFunctions()
{
Map<String, FREFunction> functionMap = new HashMap<String, FREFunction>();
functionMap.put("notifyUser", new ToolsNotifyFunction());
return functionMap;
}
void notifyUser()
{
Log.d("bla-bla-bla", "Just bla");
// look up the notification manager service
NotificationManager nm = (NotificationManager)this.getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
// The details of our fake message
CharSequence from = "Hello";
CharSequence message = "Some message!";
// The PendingIntent to launch our activity if the user selects this
// notification. Note the use of FLAG_CANCEL_CURRENT so that, if there
// is already an active matching pending intent, cancel it and replace
// it with the new array of Intents.
Intent k = new Intent(this.getActivity().getApplicationContext(), ToolsExtensionContext.class);
PendingIntent contentIntent = PendingIntent.getService(this.getActivity().getApplicationContext(),
0, k , PendingIntent.FLAG_CANCEL_CURRENT);
// The ticker text, this uses a formatted string so our message could be localized
String tickerText = "Tiker text";
// construct the Notification object.
Notification notif = new Notification(R.drawable.close, tickerText, System.currentTimeMillis() + 100000);
// Set the info for the views that show in the notification panel.
notif.setLatestEventInfo(this.getActivity().getApplicationContext(), from, message, null);//contentIntent);
// We'll have this notification do the default sound, vibration, and led.
// Note that if you want any of these behaviors, you should always have
// a preference for the user to turn them off.
notif.defaults = Notification.DEFAULT_ALL;
notif.flags = Notification.FLAG_AUTO_CANCEL;
// Note that we use R.layout.incoming_message_panel as the ID for
// the notification. It could be any integer you want, but we use
// the convention of using a resource id for a string related to
// the notification. It will always be a unique number within your
// application.
nm.notify(1, notif);
}
}