use of android.content.Intent in project cw-omnibus by commonsguy.
the class FreecarTileService method onClick.
@Override
public void onClick() {
super.onClick();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String cnFlat = prefs.getString(PREF_TO_LAUNCH, null);
if (cnFlat != null) {
ComponentName cn = ComponentName.unflattenFromString(cnFlat);
try {
ActivityInfo info = getPackageManager().getActivityInfo(cn, 0);
ActivityInfo.WindowLayout layout = info.windowLayout;
Intent i = new Intent().setComponent(cn).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Point size = new Point();
getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getSize(size);
if (layout == null) {
size.x = size.x / 2;
size.y = size.y / 2;
} else {
if (layout.widthFraction > 0.0f) {
size.x = Math.max(layout.minWidth, (int) (size.x * layout.widthFraction));
} else {
size.x = layout.width;
}
if (layout.heightFraction > 0.0f) {
size.y = Math.max(layout.minHeight, (int) (size.y * layout.heightFraction));
} else {
size.y = layout.height;
}
}
ActivityOptions opts = ActivityOptions.makeBasic().setLaunchBounds(new Rect(0, 0, size.x, size.y));
startActivity(i, opts.toBundle());
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Exception trying to launch activity", e);
toast(R.string.msg_sorry);
}
} else {
toast(R.string.msg_choose);
}
}
use of android.content.Intent in project cw-omnibus by commonsguy.
the class Launchalot method onListItemClick.
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
ResolveInfo launchable = adapter.getItem(position);
ActivityInfo activity = launchable.activityInfo;
ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(name);
startActivity(i);
}
use of android.content.Intent in project cw-omnibus by commonsguy.
the class InterpreterService method success.
private void success(Intent intent, Bundle result) {
Intent data = new Intent();
data.putExtras(result);
data.putExtra(RESULT_CODE, SUCCESS);
send(intent, data);
}
use of android.content.Intent in project cw-omnibus by commonsguy.
the class QuickSender method save.
public void save(View v) {
Intent shortcut = new Intent(Intent.ACTION_SEND);
TextView addr = (TextView) findViewById(R.id.addr);
TextView subject = (TextView) findViewById(R.id.subject);
TextView body = (TextView) findViewById(R.id.body);
TextView name = (TextView) findViewById(R.id.name);
if (!TextUtils.isEmpty(addr.getText())) {
shortcut.putExtra(Intent.EXTRA_EMAIL, new String[] { addr.getText().toString() });
}
if (!TextUtils.isEmpty(subject.getText())) {
shortcut.putExtra(Intent.EXTRA_SUBJECT, subject.getText().toString());
}
if (!TextUtils.isEmpty(body.getText())) {
shortcut.putExtra(Intent.EXTRA_TEXT, body.getText().toString());
}
shortcut.setType("text/plain");
Intent result = new Intent();
result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut);
result.putExtra(Intent.EXTRA_SHORTCUT_NAME, name.getText().toString());
result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
setResult(RESULT_OK, result);
finish();
}
use of android.content.Intent in project cw-omnibus by commonsguy.
the class ResolveActivityDemoActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PackageManager mgr = getPackageManager();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://commonsware.com"));
ResolveInfo ri = mgr.resolveActivity(i, PackageManager.MATCH_DEFAULT_ONLY);
Toast.makeText(this, ri.loadLabel(mgr), Toast.LENGTH_LONG).show();
startActivity(i);
finish();
}
Aggregations