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);
}
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);
}
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);
}
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();
}
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);
}
Aggregations