当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ACTION_MAIN属性代码示例

本文整理汇总了Java中android.content.Intent.ACTION_MAIN属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_MAIN属性的具体用法?Java Intent.ACTION_MAIN怎么用?Java Intent.ACTION_MAIN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_MAIN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAppOpenIntentByPackageName

public static Intent getAppOpenIntentByPackageName(Context context, String packageName) {
    // MainActivity完整名
    String mainAct = null;
    // 根据包名寻找MainActivity
    PackageManager pkgMag = context.getPackageManager();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK);

    List<ResolveInfo> list = pkgMag.queryIntentActivities(intent, PackageManager.GET_ACTIVITIES);
    for (int i = 0; i < list.size(); i++) {
        ResolveInfo info = list.get(i);
        if (info.activityInfo.packageName.equals(packageName)) {
            mainAct = info.activityInfo.name;
            break;
        }
    }
    if (TextUtils.isEmpty(mainAct)) {
        return null;
    }
    intent.setComponent(new ComponentName(packageName, mainAct));
    return intent;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:23,代码来源:CommonUtil.java

示例2: connectSrcHandlerToPackageSync

/**
 * Connect handler to named package/class synchronously.
 *
 * @param srcContext is the context of the source
 * @param srcHandler is the hander to receive CONNECTED & DISCONNECTED
 *            messages
 * @param dstPackageName is the destination package name
 * @param dstClassName is the fully qualified class name (i.e. contains
 *            package name)
 *
 * @return STATUS_SUCCESSFUL on success any other value is an error.
 */
public int connectSrcHandlerToPackageSync(
        Context srcContext, Handler srcHandler, String dstPackageName, String dstClassName) {
    if (DBG) log("connect srcHandler to dst Package & class E");

    mConnection = new AsyncChannelConnection();

    /* Initialize the source information */
    mSrcContext = srcContext;
    mSrcHandler = srcHandler;
    mSrcMessenger = new Messenger(srcHandler);

    /*
     * Initialize destination information to null they will
     * be initialized when the AsyncChannelConnection#onServiceConnected
     * is called
     */
    mDstMessenger = null;

    /* Send intent to create the connection */
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName(dstPackageName, dstClassName);
    boolean result = srcContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    if (DBG) log("connect srcHandler to dst Package & class X result=" + result);
    return result ? STATUS_SUCCESSFUL : STATUS_BINDING_UNSUCCESSFUL;
}
 
开发者ID:jasonwang18,项目名称:pluginMVPM,代码行数:37,代码来源:AsyncChannel.java

示例3: onClick

@Override
public void onClick(View view) {
    if (view.getId() == R.id.choice_tv) {
        PreferenceManager.getDefaultSharedPreferences(getActivity())
                .edit()
                .putString(UI_CHOICE_LEANBACK_KEY, UI_CHOICE_LEANBACK_TV_VALUE) // string definitions in preference_video.xml and in @array/ui_mode_leanback_entryvalues
                .commit();

    }
    else if (view.getId() == R.id.choice_tablet) {
        PreferenceManager.getDefaultSharedPreferences(getActivity())
                .edit()
                .putString(UI_CHOICE_LEANBACK_KEY, UI_CHOICE_LEANBACK_TABLET_VALUE) // string definitions in preference_video.xml and in @array/ui_mode_leanback_entryvalues
                .commit();
    }
    dismiss();

    // Quit the current activity and relaunch the entry acivity
    getActivity().finish();

    Intent i = new Intent(Intent.ACTION_MAIN);
    i.setClass(getActivity(), EntryActivity.class);
    startActivity(i);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:24,代码来源:UiChoiceDialog.java

示例4: recommendTest

private void recommendTest(String recName, String productID, String productCat, int countCheck)
{
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(RecommendationActivity.RECOMMENDATION_NAME, recName);
    intent.putExtra(RecommendationActivity.RECOMMENDATION_PRODUCT_ID, productID);
    intent.putExtra(RecommendationActivity.RECOMMENDATION_PRODUCT_CAT, productCat);
    mActivityRule.launchActivity(intent);
    //Wait for recommendation request done
    while (!mActivityRule.getActivity().isRequestFinished()) {
        getInstrumentation().waitForIdleSync();
    }

    //Check results
    assertEquals(WebtrekkRecommendations.QueryRecommendationResult.RECEIVED_OK, mActivityRule.getActivity().getLastResult());

    if (countCheck > 0)
      assertTrue(mActivityRule.getActivity().getRecommendationCount() >= countCheck);
    else
      assertEquals(0, mActivityRule.getActivity().getRecommendationCount());
    assertTrue(mActivityRule.getActivity().isUsedUIThread());
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:22,代码来源:RecommendationsTest.java

示例5: loadApplications

public static List<AppInfo> loadApplications(Context context) {
	PackageManager packageManager = context.getPackageManager();
	Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
	mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
	List<ResolveInfo> intentActivities = packageManager.queryIntentActivities(mainIntent, 0);
	List<AppInfo> entries = new ArrayList<>();

	if (intentActivities != null) {
		for (ResolveInfo resolveInfo : intentActivities) {
			if (!context.getPackageName().equals(resolveInfo.activityInfo.packageName))
				entries.add(new AppInfo(packageManager, resolveInfo));
		}
	}

	Collections.sort(entries, new Comparator<AppInfo>() {
		@Override
		public int compare(AppInfo lhs, AppInfo rhs) {
			return lhs.getName().compareToIgnoreCase(rhs.getName());
		}
	});
	return entries;
}
 
开发者ID:alescdb,项目名称:LauncherTV,代码行数:22,代码来源:Utils.java

示例6: onBackPressed

@Override
public void onBackPressed() {
    if (doubleBackToExitPressedOnce) {
        super.onBackPressed();
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        return;
    }

    this.doubleBackToExitPressedOnce = true;
    Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();

    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            doubleBackToExitPressedOnce=false;
        }
    }, 2000);
}
 
开发者ID:NullPointersInc,项目名称:Bella-Android,代码行数:22,代码来源:MainActivity.java

示例7: onSelected

@Override
public void onSelected(int buttonIndex) {
	Intent intent = new Intent(Intent.ACTION_MAIN);
	intent.setClassName("com.android.settings", "com.android.settings.wifi.WifiSettings");
	mActivity.startActivitiesSafely(intent, new Intent(Settings.ACTION_WIRELESS_SETTINGS), new Intent(
			Settings.ACTION_WIFI_SETTINGS));
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:7,代码来源:WiFiSettingHandler.java

示例8: onBackPressed

@Override
public void onBackPressed() {
    if (exitOnBackPressed)
    {
        // Exit the app.
        // If logged out from the main activity pressing back in the LoginActivity will get me back to the Main so this have to be done.
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
    else super.onBackPressed();

}
 
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:14,代码来源:ChatSDKAbstractLoginActivity.java

示例9: startSubtitlesWizard

protected void startSubtitlesWizard(String videoPath) {
    if (videoPath != null && videoPath.length() > 0) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setClass(getActivity(), SubtitlesWizardActivity.class);
        intent.setData(Uri.parse(videoPath));
        startActivity(intent);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:8,代码来源:Browser.java

示例10: onServiceConnected

public void onServiceConnected(ComponentName classname, IBinder obj) {
    mService = IMediaPlaybackService.Stub.asInterface(obj);
    startPlayback();
    try {
        // Assume something is playing when the service says it is,
        // but also if the audio ID is valid but the service is paused.
        if (mService.getAudioId() >= 0 || mService.isPlaying()
                || mService.getPath() != null) {
            // something is playing now, we're done
            mRepeatButton.setVisibility(View.VISIBLE);
            mShuffleButton.setVisibility(View.VISIBLE);
            setRepeatButtonImage();
            setShuffleButtonImage();
            setPauseButtonImage();
            return;
        }
    } catch (RemoteException ex) {
    }
    // Service is dead or not playing anything. If we got here as part
    // of a "play this file" Intent, exit. Otherwise go to the Music
    // app start screen.
    if (getIntent().getData() == null) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setClass(MediaLockscreenActivity.this,
                OnlineActivity.class);
        startActivity(intent);
    }
    finish();
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:30,代码来源:MediaLockscreenActivity.java

示例11: clickExit

public void clickExit(MenuItem item)
{
    Intent intent=new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    metr.stop();
    startActivity(intent);
    finish();
}
 
开发者ID:JosielSantos,项目名称:android-metronome,代码行数:9,代码来源:Base.java

示例12: startActivityForProfile

public void startActivityForProfile(ComponentName component, UserHandleCompat user,
        Rect sourceBounds, Bundle opts) {
    Intent launchIntent = new Intent(Intent.ACTION_MAIN);
    launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    launchIntent.setComponent(component);
    launchIntent.setSourceBounds(sourceBounds);
    launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(launchIntent, opts);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:LauncherAppsCompatV16.java

示例13: onBackPressed

@Override
public void onBackPressed() { //Método de back do botão do celular

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);

    } else {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        startActivity(intent);
    }

}
 
开发者ID:gabriel-silva,项目名称:MapaDeIgarassu,代码行数:15,代码来源:MapActivity.java

示例14: startActivity

private XulHttpServerResponse startActivity(XulHttpServerRequest request, String[] params) {
	if (params == null) {
		return null;
	}
	String activity = params.length > 0 ? params[0].trim() : null;
	String action = params.length > 1 ? params[1].trim() : Intent.ACTION_MAIN;
	String category = params.length > 2 ? params[2].trim() : null;

	return startActivity(request, activity, action, category);
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:10,代码来源:XulDebugServer.java

示例15: getLauncherPackageName

/**
 * 获取正在运行桌面包名
 */
public static String getLauncherPackageName(Context context) {
    final Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    final ResolveInfo res = context.getPackageManager().resolveActivity(intent, 0);
    return res.activityInfo.packageName;
}
 
开发者ID:XYScience,项目名称:StopApp,代码行数:9,代码来源:CommonUtil.java


注:本文中的android.content.Intent.ACTION_MAIN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。