本文整理匯總了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());
}