Search in sources :

Example 11 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)

Example 12 with Intent

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

the class ListSamples method activityIntent.

protected Intent activityIntent(String pkg, String componentName) {
    Intent result = new Intent();
    result.setClassName(pkg, componentName);
    return result;
}
Also used : Intent(android.content.Intent)

Example 13 with Intent

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

the class EU4You method onCountrySelected.

@Override
public void onCountrySelected(Country c) {
    String url = getString(c.url);
    if (details != null && details.isVisible()) {
        details.loadUrl(url);
    } else {
        Intent i = new Intent(this, DetailsActivity.class);
        i.putExtra(DetailsActivity.EXTRA_URL, url);
        startActivity(i);
    }
}
Also used : Intent(android.content.Intent)

Example 14 with Intent

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

the class EU4You method onCountrySelected.

@Override
public void onCountrySelected(Country c) {
    String url = getString(c.url);
    if (details != null && details.isVisible()) {
        details.loadUrl(url);
    } else {
        Intent i = new Intent(this, DetailsActivity.class);
        i.putExtra(DetailsActivity.EXTRA_URL, url);
        startActivity(i);
    }
}
Also used : Intent(android.content.Intent)

Example 15 with Intent

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

the class DownloaderDemo method doTheDownload.

public void doTheDownload() {
    Intent i = new Intent(this, Downloader.class);
    i.setData(Uri.parse("https://commonsware.com/Android/excerpt.pdf"));
    i.putExtra(Downloader.EXTRA_MESSENGER, new Messenger(handler));
    startService(i);
}
Also used : Intent(android.content.Intent) Messenger(android.os.Messenger)

Aggregations

Intent (android.content.Intent)13686 PendingIntent (android.app.PendingIntent)2730 View (android.view.View)1004 ComponentName (android.content.ComponentName)943 Bundle (android.os.Bundle)841 ResolveInfo (android.content.pm.ResolveInfo)743 Uri (android.net.Uri)707 Context (android.content.Context)663 RemoteException (android.os.RemoteException)657 TextView (android.widget.TextView)624 PackageManager (android.content.pm.PackageManager)524 Test (org.junit.Test)509 IntentFilter (android.content.IntentFilter)496 ArrayList (java.util.ArrayList)465 ActivityNotFoundException (android.content.ActivityNotFoundException)376 ImageView (android.widget.ImageView)375 BroadcastReceiver (android.content.BroadcastReceiver)354 IOException (java.io.IOException)353 File (java.io.File)337 Notification (android.app.Notification)283