当我点击钛金属通知时,我想在应用程序中打开某个页面 我正在使用titanium SDK 3.5.1 我已经创建了一个隐藏应用程序的意图,但它打开了索引页面
var intent1 = Ti.Android.createIntent({
flags : Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP,
className : 'co.ntime.audioPlayer.AudioplayerActivity',
action : Ti.Android.ACTION_MAIN
});
var pending1 = Ti.Android.createPendingIntent({
activity : Ti.Android.currentActivity,
intent : intent1,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
flags : Titanium.Android.FLAG_ACTIVITY_NEW_TASK
});
Ti.Android.currentActivity.addEventListener('newintent', function(e) {
Ti.API.info('caught intent!');
var page1 = Alloy.createController('page1').getView();
$.index.add(page1);
});
但它没有进入新的意图事件
答案 0 :(得分:0)
你可以尝试这个
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(com.project.R.drawable.app_icon, "heading title", System.currentTimeMillis());
CharSequence from = "application name";
CharSequence message = "message which you want to show";
intent = new Intent(MyActivity.this,ShowActivity.class);
intent.putExtra("NotifID", notifID);
pendingIntent= PendingIntent.getActivity(MyActivity.this, notifID, intent, PendingIntent.FLAG_UPDATE_CURRENT| PendingIntent.FLAG_ONE_SHOT);
notif.setLatestEventInfo(this, from, message, intent);
notif.flags |= Notification.FLAG_AUTO_CANCEL;
notif.vibrate = new long[] { 100, 250, 100, 500 };
nm.notify(notifID, notif);
finish();
答案 1 :(得分:0)
你必须在推送通知中发送额外字段作为字符串,你可以检查onMessage()方法然后根据你可以使用if else设置Activity类的额外字段字符串。
答案 2 :(得分:0)
在我的项目中,我在推送通知中添加了额外字段,例如。 pushID。然后在打开通知时读取该字段,并根据该字段的值,打开与该值对应的特定页面。
离。 pushID = 1,访问登录页面 EX2。 pushID = 2,访问联系人页面等等......
答案 3 :(得分:0)
我发现这里的答案是代码
/*
* Resizing image size
*/
public static Bitmap decodeFile(String filePath, int WIDTH, int HIGHT) {
try {
File f = new File(filePath);
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f), null, o);
final int REQUIRED_WIDTH = WIDTH;
final int REQUIRED_HIGHT = HIGHT;
int scale = 1;
while (o.outWidth / scale / 2 >= REQUIRED_WIDTH
&& o.outHeight / scale / 2 >= REQUIRED_HIGHT)
scale *= 2;
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}
Bitmap image = decodeFile(_filePaths.get(position), imageWidth, imageHeight);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(imageWidth,
imageWidth));
imageView.setImageBitmap(image);
答案 4 :(得分:0)
试试这个
var theNextWindow = Alloy.createController("PageName");
Alloy.Globals.pageStack.open(theNextWindow.getView());