本文整理汇总了Java中android.widget.RemoteViews.setBitmap方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setBitmap方法的具体用法?Java RemoteViews.setBitmap怎么用?Java RemoteViews.setBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setBitmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getBooleanExtra(ArcadeCommon.STATUS_RESET_SCORE, false)) {
score = 0;
} else {
score += intent.getIntExtra(ArcadeCommon.STATUS_INCREMENT_SCORE, 0);
}
RemoteViews notifViews = new RemoteViews(context.getPackageName(),
R.layout.status_notification);
notifViews.setTextViewText(R.id.title, getString(titleResID));
notifViews.setImageViewResource(R.id.notif_icon, notifIconResID);
NotificationManager notifMgr =
(NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
notifViews.setTextViewText(R.id.score, getString(R.string.score, score));
int newLevel = intent.getIntExtra(ArcadeCommon.STATUS_LEVEL, level);
if (newLevel != level) {
setLevel(newLevel);
}
if (level >= 0) {
notifViews.setTextViewText(R.id.level, getString(R.string.level, level));
}
setLives(intent.getIntExtra(ArcadeCommon.STATUS_LIVES, lives));
if (previewActive) {
return;
}
notifViews.removeAllViews(R.id.lives_area);
if (lives < 0) {
// Game over, man
RemoteViews gameOver = new RemoteViews(getPackageName(), R.layout.status_text);
gameOver.setTextViewText(R.id.status_text, "Game Over");
notifViews.addView(R.id.lives_area, gameOver);
if (!isPaused) {
onPause();
}
} else {
Bitmap lifeBitmap = BitmapFactory.decodeResource(getResources(), lifeIconResId);
for (int i = 0; i < lives; i++) {
RemoteViews thisLife = new RemoteViews(getPackageName(), R.layout.status_life_icon);
thisLife.setBitmap(R.id.life_icon, "setImageBitmap", lifeBitmap);
notifViews.addView(R.id.lives_area, thisLife);
}
}
Bitmap pauseBtn = BitmapFactory.decodeResource(getResources(),
isPaused || (readyTime > 0)
? R.drawable.ic_play_circle_outline_white_48dp
: R.drawable.ic_pause_circle_outline_white_48dp);
notifViews.setBitmap(R.id.play_pause, "setImageBitmap", pauseBtn);
notifViews.setOnClickPendingIntent(R.id.play_pause,
PendingIntent.getBroadcast(context, 0,
new Intent(ArcadeCommon.ACTION_PAUSE), 0));
final NotificationCompat.Builder notif = new NotificationCompat.Builder(context)
.setSmallIcon(notifIconResID)
.setContent(notifViews)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setVisibility(VISIBILITY_SECRET); // keep the scroreboard off the lock screen
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// This forces a heads-up notification
notif.setVibrate(new long[0]);
}
notifMgr.notify(0, notif.build());
}