我正在尝试使用操作创建通知,但我无法将这行代码转换为 Javascript:
Intent resultIntent = new Intent(this, ResultActivity.class);
来自https://developer.android.com/training/notify-user/build-notification.html
任何人都可以帮忙吗?或者有一个功能示例?谢谢
我正在尝试使用操作创建通知,但我无法将这行代码转换为 Javascript:
Intent resultIntent = new Intent(this, ResultActivity.class);
来自https://developer.android.com/training/notify-user/build-notification.html
任何人都可以帮忙吗?或者有一个功能示例?谢谢
有用!
var app = require('application');
var packageName = app.android.context.getPackageName();
var launchIntent = app.android.context.getPackageManager().getLaunchIntentForPackage(packageName);
var className = launchIntent.getComponent().getClassName();
var tns = className + '.class';
var intent = new android.content.Intent(app.android.context, eval(tns));
var pIntent = android.app.PendingIntent.getActivity(app.android.context, 0, intent, 0);
var resImg = app.android.context.getResources().getIdentifier('icon' , 'drawable', app.android.context.getPackageName());
var mBuilder = new android.support.v4.app.NotificationCompat.Builder(app.android.context);
mBuilder.setSmallIcon(resImg);
mBuilder.setContentTitle('My notification');
mBuilder.setContentText('Hello World!');
mBuilder.addAction(resImg, 'see', pIntent);
var mNotificationId = 001;
var sytemservice = app.android.context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
sytemservice.notify(mNotificationId, mBuilder.build());
用模拟器 android 4.2.2 测试