Search in sources :

Example 26 with ComponentName

use of android.content.ComponentName 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 27 with ComponentName

use of android.content.ComponentName in project cw-omnibus by commonsguy.

the class LockMeNowActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    cn = new ComponentName(this, AdminReceiver.class);
    mgr = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
}
Also used : ComponentName(android.content.ComponentName)

Example 28 with ComponentName

use of android.content.ComponentName in project cw-omnibus by commonsguy.

the class AdminReceiver method onEnabled.

@Override
public void onEnabled(Context ctxt, Intent intent) {
    ComponentName cn = new ComponentName(ctxt, AdminReceiver.class);
    DevicePolicyManager mgr = (DevicePolicyManager) ctxt.getSystemService(Context.DEVICE_POLICY_SERVICE);
    mgr.setPasswordQuality(cn, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
    onPasswordChanged(ctxt, intent);
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) ComponentName(android.content.ComponentName)

Example 29 with ComponentName

use of android.content.ComponentName in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ComponentName cn = new ComponentName(this, AdminReceiver.class);
    DevicePolicyManager mgr = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
    if (mgr.isAdminActive(cn)) {
        int msgId;
        if (mgr.isActivePasswordSufficient()) {
            msgId = R.string.compliant;
        } else {
            msgId = R.string.not_compliant;
        }
        Toast.makeText(this, msgId, Toast.LENGTH_LONG).show();
    } else {
        Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cn);
        intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getString(R.string.device_admin_explanation));
        startActivity(intent);
    }
    finish();
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 30 with ComponentName

use of android.content.ComponentName in project ActionBar-PullToRefresh by chrisbanes.

the class MainActivity method onListItemClick.

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    ActivityInfo info = (ActivityInfo) l.getItemAtPosition(position);
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(this, info.name));
    startActivity(intent);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)2524 Intent (android.content.Intent)941 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)266 PendingIntent (android.app.PendingIntent)248 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)240 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)137 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)130 IBinder (android.os.IBinder)128 IOException (java.io.IOException)124 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)95 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)66