Intent addCategory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent addCategory method.

This code example shows how to use the following methods:addCategory, setFlags
 
public final class IntentHelper { 
    private static final String TAG = IntentHelper.class.getSimpleName();
 
    public static Intent getLauncherIntent() {
        final Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        return intent;
    } 
 
    public static void goHomePage(final Context context, final int page) {
        final Intent intent = new Intent(context, HomePage.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(Constants.EXTRA_PAGE, page);
        context.startActivity(intent);
    } 
 
    public static void goLoginPage(final Context context) {
        final Intent intent = new Intent(context, LoginPage.class);
7
CodeRank
This code example shows how to use the following methods:addCategory, addFlags, sleep
     * Launches and activity and queries for errors. 
     * @param packageName {@link String} the package name of the application to launch. 
     * @return  {@link Collection} of {@link ProcessErrorStateInfo} detected during the app launch. 
     */ 
    private Collection<ProcessErrorStateInfo> launchActivity(String packageName) {
        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
        Intent intent = mPackageManager.getLaunchIntentForPackage(packageName);
 
        // We check for any Crash or ANR dialogs that are already up, and we ignore them.  This is 
        // so that we don't report crashes that were caused by prior apps (which those particular 
        // tests should have caught and reported already).  Otherwise, test failures would cascade 
        // from the initial broken app to many/all of the tests following that app's launch. 
        final Collection<ProcessErrorStateInfo> preErr = mActivityManager.getProcessesInErrorState();
 
        // Launch Activity 
        mContext.startActivity(intent);
 

7
CodeRank
This code example shows how to use the following methods:addCategory, setComponent
        startActivity(intent);
    } 
 
    @Override 
    public boolean onLongClick(View v) {
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.setComponent(ComponentName
                .unflattenFromString("com.aokp.romcontrol/.ROMControlActivity"));
        intent.addCategory("android.intent.category.LAUNCHER");
 
        startActivity(intent);
        return super.onLongClick(v);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:addCategory
		return super.onOptionsItemSelected(item);
	} 
 
	protected void exit() { 
		TwitterService.unschedule(this);
		Intent i = new Intent(Intent.ACTION_MAIN);
		i.addCategory(Intent.CATEGORY_HOME);
		startActivity(i);
	} 
 
	protected void launchActivity(Intent intent) {
		// TODO: probably don't need this result chaining to finish upon logout. 
		// since the subclasses have to check in onResume. 
		startActivityForResult(intent, REQUEST_CODE_LAUNCH_ACTIVITY);
	} 
 
	protected void launchDefaultActivity() { 
		Intent intent = new Intent();
		intent.setClass(this, TwitterActivity.class);
		startActivity(intent);
6
CodeRank
This code example shows how to use the following methods:addCategory
 
public class UnderdevelopedSettings extends LauncherActivity {
 
    @Override 
    protected Intent getTargetIntent() {
        Intent targetIntent = new Intent(Intent.ACTION_MAIN, null);
        targetIntent.addCategory(Intent.CATEGORY_DEVELOPMENT_PREFERENCE);
        return targetIntent;
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:addCategory, putExtra
This code example shows how to use the following methods:addCategory, setComponent
        super.init(c, style);
    } 
     
    @Override 
    public void onClick(View v) {
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.setComponent(ComponentName
                .unflattenFromString("com.android.deskclock.AlarmProvider"));
        intent.addCategory("android.intent.category.LAUNCHER");
        vibrateOnTouch(); 
        collapseStatusBar(); 
        dismissKeyguard(); 
        startActivity(intent);
    } 
 
    @Override 
    public boolean onLongClick(View v) {
        startActivity(new Intent(Intent.ACTION_QUICK_CLOCK));
        return super.onLongClick(v);
    } 
7
CodeRank
This code example shows how to use the following methods:addCategory
 
        String url = download.getHtmlUrl();
        if (TextUtils.isEmpty(url))
            return; 
 
        Intent intent = new Intent(ACTION_VIEW, Uri.parse(url));
        intent.addCategory(CATEGORY_BROWSABLE);
        startActivity(intent);
    } 
 
    private void openCommitComment(Event event) {
        Repository repo = RepositoryEventMatcher.getRepository(event.getRepo(),
                event.getActor(), event.getOrg());
        if (repo == null)
            return; 
 
        CommitCommentPayload payload = (CommitCommentPayload) event
                .getPayload(); 
        CommitComment comment = payload.getComment();
        if (comment == null)
8
CodeRank
This code example shows how to use the following methods:addCategory, queryIntentActivities
    } 
 
    private List<ResolveInfo> mApps;
 
    private void loadApps() { 
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
 
        mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    } 
 
    public class AppsAdapter extends BaseAdapter {
        public AppsAdapter() { 
        } 
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i;
 
            if (convertView == null) {
                i = new ImageView(Grid1.this);
7
CodeRank
This code example shows how to use the following methods:addCategory, setComponent, setFlags

Related Intent addCategory Questions & Answers:

Other Intent addCategory Examples

29:	    intent.setType("image/*");
30:	    intent.setAction(Intent.ACTION_GET_CONTENT);
31:	    intent.addCategory(Intent.CATEGORY_OPENABLE);
32:	    startActivityForResult(intent, REQUEST_CODE);
33:	  }

Read More

6:	    // in our menu. The offering app must include a category value of Intent.CATEGORY_ALTERNATIVE.
7:	    Intent intent = new Intent(null, dataUri);
8:	    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
9:	
10:	    // Search and populate the menu with acceptable offering applications.

Read More

addCategory Method Overview
Add a new category to the intent.
See Code Examples for other Android Intent Methods: