use of android.widget.RemoteViews in project cw-advandroid by commonsguy.
the class AppWidget method buildUpdate.
private RemoteViews buildUpdate(Context ctxt, int[] appWidgetIds) {
RemoteViews updateViews = new RemoteViews(ctxt.getPackageName(), R.layout.widget);
Intent i = new Intent(ctxt, AppWidget.class);
i.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
updateViews.setImageViewResource(R.id.left_die, IMAGES[(int) (Math.random() * 6)]);
updateViews.setOnClickPendingIntent(R.id.left_die, pi);
updateViews.setImageViewResource(R.id.right_die, IMAGES[(int) (Math.random() * 6)]);
updateViews.setOnClickPendingIntent(R.id.right_die, pi);
updateViews.setOnClickPendingIntent(R.id.background, pi);
return (updateViews);
}
use of android.widget.RemoteViews in project cw-andtutorials by commonsguy.
the class AppWidget method onUpdate.
@Override
public void onUpdate(Context ctxt, AppWidgetManager mgr, int[] appWidgetIds) {
ComponentName me = new ComponentName(ctxt, AppWidget.class);
RemoteViews updateViews = new RemoteViews("apt.tutorial", R.layout.widget);
RestaurantHelper helper = new RestaurantHelper(ctxt);
try {
Cursor c = helper.getReadableDatabase().rawQuery("SELECT COUNT(*) FROM restaurants", null);
c.moveToFirst();
int count = c.getInt(0);
c.close();
if (count > 0) {
int offset = (int) (count * Math.random());
String[] args = { String.valueOf(offset) };
c = helper.getReadableDatabase().rawQuery("SELECT name FROM restaurants LIMIT 1 OFFSET ?", args);
c.moveToFirst();
updateViews.setTextViewText(R.id.name, c.getString(0));
} else {
updateViews.setTextViewText(R.id.name, ctxt.getString(R.string.empty));
}
} finally {
helper.close();
}
mgr.updateAppWidget(me, updateViews);
}
use of android.widget.RemoteViews in project SimplifyReader by chentao0707.
the class DownloadListenerImpl method createNotification.
/**
* TODO 创建通知对象
*/
private static Notification createNotification(Context c) {
Notification n = new Notification();
Class<? extends Activity> cacheActivity = YoukuPlayerApplication.instance.getCachingActivityClass();
Intent i = new Intent(c, cacheActivity);
i.putExtra("go", "downloading");
n.contentIntent = PendingIntent.getActivity(c, 4, i, PendingIntent.FLAG_UPDATE_CURRENT);
n.contentView = new RemoteViews(c.getPackageName(), R.layout.notify);
return n;
}
use of android.widget.RemoteViews in project cw-advandroid by commonsguy.
the class Plugin method onReceive.
@Override
public void onReceive(Context ctxt, Intent i) {
if (ACTION_CALL_FOR_PLUGINS.equals(i.getAction())) {
Intent registration = new Intent(ACTION_REGISTER_PLUGIN);
registration.setPackage(HOST_PACKAGE);
registration.putExtra(EXTRA_COMPONENT, new ComponentName(ctxt, getClass()));
ctxt.sendBroadcast(registration);
} else if (ACTION_CALL_FOR_CONTENT.equals(i.getAction())) {
RemoteViews rv = new RemoteViews(ctxt.getPackageName(), R.layout.plugin);
Intent update = new Intent(ACTION_DELIVER_CONTENT);
update.setPackage(HOST_PACKAGE);
update.putExtra(EXTRA_CONTENT, rv);
ctxt.sendBroadcast(update);
}
}
use of android.widget.RemoteViews in project cw-omnibus by commonsguy.
the class Downloader method buildForeground.
private NotificationCompat.Builder buildForeground(String filename) {
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
RemoteViews content = new RemoteViews(getPackageName(), R.layout.notif_content);
content.setTextViewText(android.R.id.title, "Downloading: " + filename);
b.setOngoing(true).setContent(content).setSmallIcon(android.R.drawable.stat_sys_download);
return (b);
}
Aggregations