如何访问 ARE(我的包 R)以在服务中使用 Drawable 图像
How can I access R (my package's R) to use Drwable image in Service
public class HelloService extends Service {
...
..
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent resultIntent = new Intent(HelloService.this,MapActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder mBuilder = new Notification.Builder(this);
// Notification.InboxStyle style = new Notification.InboxStyle(mBuilder);
//
//
// mBuilder.setStyle(style);
mBuilder.setTicker("Notification.Builder");
mBuilder.setWhen(System.currentTimeMillis());
mBuilder.setNumber(10);
mBuilder.setSmallIcon(android.support.v4.R.drawable.notification_icon_background);
mBuilder.setContentTitle(title);
mBuilder.setContentText(contents);
mBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
mBuilder.setContentIntent(pendingIntent);
mBuilder.setAutoCancel(true);
***mBuilder.setSmallIcon(R.drawable ....);***
*//这里想用图标来显示。但出于某种原因,
我不能使用 R.drawable(com.org.smartapp 这意味着我的包裹)。只有 android.support.v4 等....如何访问可绘制文件以将其用作图标?在扩展 activity 的其他 Java class 文件上,可以像下面那样具有 R.drawable 访问权限。 *
please click to see
can't find my packages one in here
mBuilder.setPriority(Notification.PRIORITY_MIN);
nm.notify(111, mBuilder.build());
...
}
试试这个
Drawable drawable=ContextCompat.getDrawable(HelloService.this,R.drawable.ic_launcher_round);
public class HelloService extends Service {
...
..
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent resultIntent = new Intent(HelloService.this,MapActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder mBuilder = new Notification.Builder(this);
// Notification.InboxStyle style = new Notification.InboxStyle(mBuilder);
//
//
// mBuilder.setStyle(style);
mBuilder.setTicker("Notification.Builder");
mBuilder.setWhen(System.currentTimeMillis());
mBuilder.setNumber(10);
mBuilder.setSmallIcon(android.support.v4.R.drawable.notification_icon_background);
mBuilder.setContentTitle(title);
mBuilder.setContentText(contents);
mBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
mBuilder.setContentIntent(pendingIntent);
mBuilder.setAutoCancel(true);
***mBuilder.setSmallIcon(R.drawable ....);***
*//这里想用图标来显示。但出于某种原因, 我不能使用 R.drawable(com.org.smartapp 这意味着我的包裹)。只有 android.support.v4 等....如何访问可绘制文件以将其用作图标?在扩展 activity 的其他 Java class 文件上,可以像下面那样具有 R.drawable 访问权限。 *
please click to see
can't find my packages one in here
mBuilder.setPriority(Notification.PRIORITY_MIN);
nm.notify(111, mBuilder.build());
...
}
试试这个
Drawable drawable=ContextCompat.getDrawable(HelloService.this,R.drawable.ic_launcher_round);