Search in sources :

Example 51 with Intent

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

the class ActivityChooserModel method chooseActivity.

/**
     * Chooses a activity to handle the current intent. This will result in
     * adding a historical record for that action and construct intent with
     * its component name set such that it can be immediately started by the
     * client.
     * <p>
     * <strong>Note:</strong> By calling this method the client guarantees
     * that the returned intent will be started. This intent is returned to
     * the client solely to let additional customization before the start.
     * </p>
     *
     * @return An {@link Intent} for launching the activity or null if the
     *         policy has consumed the intent.
     *
     * @see HistoricalRecord
     * @see OnChooseActivityListener
     */
public Intent chooseActivity(int index) {
    ActivityResolveInfo chosenActivity = mActivites.get(index);
    ComponentName chosenName = new ComponentName(chosenActivity.resolveInfo.activityInfo.packageName, chosenActivity.resolveInfo.activityInfo.name);
    Intent choiceIntent = new Intent(mIntent);
    choiceIntent.setComponent(chosenName);
    if (mActivityChoserModelPolicy != null) {
        // Do not allow the policy to change the intent.
        Intent choiceIntentCopy = new Intent(choiceIntent);
        final boolean handled = mActivityChoserModelPolicy.onChooseActivity(this, choiceIntentCopy);
        if (handled) {
            return null;
        }
    }
    HistoricalRecord historicalRecord = new HistoricalRecord(chosenName, System.currentTimeMillis(), DEFAULT_HISTORICAL_RECORD_WEIGHT);
    addHisoricalRecord(historicalRecord);
    return choiceIntent;
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 52 with Intent

use of android.content.Intent in project UltimateAndroid by cymcsg.

the class DefaultIntro method loadMainActivity.

private void loadMainActivity() {
    Intent intent = new Intent(this, AppintroActivity.class);
    startActivity(intent);
}
Also used : Intent(android.content.Intent)

Example 53 with Intent

use of android.content.Intent in project UltimateAndroid by cymcsg.

the class SecondLayoutIntro method loadMainActivity.

private void loadMainActivity() {
    Intent intent = new Intent(this, AppintroActivity.class);
    startActivity(intent);
}
Also used : Intent(android.content.Intent)

Example 54 with Intent

use of android.content.Intent in project android by cSploit.

the class WifiScannerFragment method onBackPressed.

public void onBackPressed() {
    mScanReceiver.unregister();
    mConnectionReceiver.unregister();
    Bundle bundle = new Bundle();
    bundle.putBoolean(CONNECTED, mConnected);
    Intent intent = new Intent();
    intent.putExtras(bundle);
    getActivity().setResult(AppCompatActivity.RESULT_OK, intent);
    getActivity().finish();
    getActivity().overridePendingTransition(R.anim.fadeout, R.anim.fadein);
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent)

Example 55 with Intent

use of android.content.Intent in project android-betterpickers by code-troopers.

the class ListSamples method getData.

protected List<Map<String, Object>> getData(String prefix) {
    List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(INTENT_SAMPLE);
    PackageManager pm = getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
    if (null == list) {
        return myData;
    }
    String[] prefixPath;
    String prefixWithSlash = prefix;
    if (prefix.equals("")) {
        prefixPath = null;
    } else {
        prefixPath = prefix.split("/");
        prefixWithSlash = prefix + "/";
    }
    int len = list.size();
    Map<String, Boolean> entries = new HashMap<String, Boolean>();
    for (int i = 0; i < len; i++) {
        ResolveInfo info = list.get(i);
        CharSequence labelSeq = info.loadLabel(pm);
        String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name;
        if (prefixWithSlash.length() == 0 || label.startsWith(prefixWithSlash)) {
            String[] labelPath = label.split("/");
            String nextLabel = prefixPath == null ? labelPath[0] : labelPath[prefixPath.length];
            if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) {
                addItem(myData, nextLabel, activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
            } else {
                if (entries.get(nextLabel) == null) {
                    addItem(myData, nextLabel, browseIntent(prefix.equals("") ? nextLabel : prefix + "/" + nextLabel));
                    entries.put(nextLabel, true);
                }
            }
        }
    }
    Collections.sort(myData, NAME_COMPARATOR);
    return myData;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) HashMap(java.util.HashMap) Map(java.util.Map)

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