Search in sources :

Example 6 with RemoteViews

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);
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 7 with RemoteViews

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);
}
Also used : RemoteViews(android.widget.RemoteViews) ComponentName(android.content.ComponentName) Cursor(android.database.Cursor)

Example 8 with RemoteViews

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;
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 9 with RemoteViews

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);
    }
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 10 with RemoteViews

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);
}
Also used : RemoteViews(android.widget.RemoteViews) NotificationCompat(android.support.v4.app.NotificationCompat)

Aggregations

RemoteViews (android.widget.RemoteViews)211 Intent (android.content.Intent)83 PendingIntent (android.app.PendingIntent)75 TextView (android.widget.TextView)35 Test (org.junit.Test)35 View (android.view.View)32 Notification (android.app.Notification)30 SmallTest (android.support.test.filters.SmallTest)30 ImageView (android.widget.ImageView)28 AppWidgetManager (android.appwidget.AppWidgetManager)25 ComponentName (android.content.ComponentName)24 Bitmap (android.graphics.Bitmap)24 Bundle (android.os.Bundle)16 NavigationBarView (com.android.systemui.statusbar.phone.NavigationBarView)15 RemoteInputView (com.android.systemui.statusbar.policy.RemoteInputView)15 NotificationCompat (android.support.v4.app.NotificationCompat)14 Resources (android.content.res.Resources)12 StatusBarNotification (android.service.notification.StatusBarNotification)12 SharedPreferences (android.content.SharedPreferences)11 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)11