Search in sources :

Example 71 with Intent

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);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Rect(android.graphics.Rect) SharedPreferences(android.content.SharedPreferences) ComponentName(android.content.ComponentName) Intent(android.content.Intent) Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 72 with Intent

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

Example 73 with Intent

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

Example 74 with Intent

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

Example 75 with Intent

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();
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)30598 PendingIntent (android.app.PendingIntent)4802 Test (org.junit.Test)2560 View (android.view.View)2527 Bundle (android.os.Bundle)2094 ComponentName (android.content.ComponentName)1706 TextView (android.widget.TextView)1660 Uri (android.net.Uri)1607 Context (android.content.Context)1506 ResolveInfo (android.content.pm.ResolveInfo)1397 PackageManager (android.content.pm.PackageManager)1125 ArrayList (java.util.ArrayList)1067 IntentFilter (android.content.IntentFilter)917 ImageView (android.widget.ImageView)904 ActivityNotFoundException (android.content.ActivityNotFoundException)859 File (java.io.File)823 RemoteException (android.os.RemoteException)786 DialogInterface (android.content.DialogInterface)752 IOException (java.io.IOException)742 SharedPreferences (android.content.SharedPreferences)665