本文整理汇总了Java中android.content.Intent.hasCategory方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.hasCategory方法的具体用法?Java Intent.hasCategory怎么用?Java Intent.hasCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.hasCategory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if(!isTaskRoot()){
Intent intent = getIntent();
String action = intent.getAction();
if(intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)){
finish();
return;
}
}
inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
hideSoftKeyboard();
mAppCtx = HiTalkApplication.mAppContext;
sAliveActivities.add(this);
checkAndInstallEatMark();
params = removeParams(getIntent());
}
示例2: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
//http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
// should be in launcher activity, but all app use this can avoid the problem
if(!isTaskRoot()){
Intent intent = getIntent();
String action = intent.getAction();
if(intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)){
finish();
return;
}
}
inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}
示例3: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
//http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
// should be in launcher activity, but all app use this can avoid the problem
if(!isTaskRoot()){
Intent intent = getIntent();
String action = intent.getAction();
if(intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)){
finish();
return;
}
}
inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}
示例4: isLauncherAppTarget
import android.content.Intent; //导入方法依赖的package包/类
/**
* Returns true if the intent is a valid launch intent for a launcher activity of an app.
* This is used to identify shortcuts which are different from the ones exposed by the
* applications' manifest file.
*
* @param launchIntent The intent that will be launched when the shortcut is clicked.
*/
public static boolean isLauncherAppTarget(Intent launchIntent) {
if (launchIntent != null
&& Intent.ACTION_MAIN.equals(launchIntent.getAction())
&& launchIntent.getComponent() != null
&& launchIntent.getCategories() != null
&& launchIntent.getCategories().size() == 1
&& launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER)
&& TextUtils.isEmpty(launchIntent.getDataString())) {
// An app target can either have no extra or have ItemInfo.EXTRA_PROFILE.
Bundle extras = launchIntent.getExtras();
if (extras == null) {
return true;
} else {
Set<String> keys = extras.keySet();
return keys.size() == 1 && keys.contains(ItemInfo.EXTRA_PROFILE);
}
};
return false;
}
示例5: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
ActivityManagerUtil.getInstance().pushOneActivity(this);
//http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
// should be in launcher activity, but all app use this can avoid the problem
if(!isTaskRoot()){
Intent intent = getIntent();
String action = intent.getAction();
if(intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)){
finish();
return;
}
}
inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}
示例6: isLauncherAppTarget
import android.content.Intent; //导入方法依赖的package包/类
/**
* Returns true if the intent is a valid launch intent for a launcher activity of an app.
* This is used to identify shortcuts which are different from the ones exposed by the
* applications' manifest file.
*
* @param launchIntent The intent that will be launched when the shortcut is clicked.
*/
public static boolean isLauncherAppTarget(Intent launchIntent) {
if (launchIntent != null
&& Intent.ACTION_MAIN.equals(launchIntent.getAction())
&& launchIntent.getComponent() != null
&& launchIntent.getCategories() != null
&& launchIntent.getCategories().size() == 1
&& launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER)
&& TextUtils.isEmpty(launchIntent.getDataString())) {
// An app target can either have no extra or have ItemInfo.EXTRA_PROFILE.
Bundle extras = launchIntent.getExtras();
return extras == null || extras.keySet().isEmpty();
}
return false;
}
示例7: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
//http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
// should be in launcher activity, but all app use this can avoid the problem
if(!isTaskRoot()){
Intent intent = getIntent();
String action = intent.getAction();
if(intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)){
finish();
return;
}
}
inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}
示例8: bindRecents
import android.content.Intent; //导入方法依赖的package包/类
/**
* Refreshes the recently launched applications stacked over the favorites. The number
* of recents depends on how many favorites are present.
*/
private void bindRecents() {
final PackageManager manager = getPackageManager();
final ActivityManager tasksManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
final List<ActivityManager.RecentTaskInfo> recentTasks = tasksManager.getRecentTasks(
MAX_RECENT_TASKS, 0);
final int count = recentTasks.size();
final ArrayList<ApplicationInfo> recents = new ArrayList<ApplicationInfo>();
for (int i = count - 1; i >= 0; i--) {
final Intent intent = recentTasks.get(i).baseIntent;
if (Intent.ACTION_MAIN.equals(intent.getAction()) &&
!intent.hasCategory(Intent.CATEGORY_HOME)) {
ApplicationInfo info = getApplicationInfo(manager, intent);
if (info != null) {
info.intent = intent;
if (!mFavorites.contains(info)) {
recents.add(info);
}
}
}
}
mApplicationsStack.setRecents(recents);
}
示例9: onStartActivity
import android.content.Intent; //导入方法依赖的package包/类
public static int onStartActivity(int res, IApplicationThread caller, String callingPackage, Intent intent) {
if (res >= 0 && intent != null && (intent.hasCategory(Intent.CATEGORY_HOME) || intent.hasCategory(Intent.CATEGORY_LAUNCHER))) {
ProcessRecord callerApp = getAms().getRecordForAppLocked(caller);
if (callerApp != null) {
mPreventRunning.onStartHomeActivity(callerApp.info.packageName);
}
}
return res;
}
示例10: onCreate
import android.content.Intent; //导入方法依赖的package包/类
protected void onCreate(@Nullable Bundle paramBundle) {
super.onCreate(paramBundle);
if (!isTaskRoot()) {
Intent localIntent = getIntent();
String str = localIntent.getAction();
if ((localIntent.hasCategory("android.intent.category.LAUNCHER")) && (str.equals("android.intent.action.MAIN")))
finish();
}
}
示例11: shouldIgnoreIntent
import android.content.Intent; //导入方法依赖的package包/类
/**
* Returns true if the app should ignore a given intent.
*
* @param context Android Context.
* @param intent Intent to check.
* @return true if the intent should be ignored.
*/
public boolean shouldIgnoreIntent(Context context, Intent intent) {
// Although not documented to, many/most methods that retrieve values from an Intent may
// throw. Because we can't control what packages might send to us, we should catch any
// Throwable and then fail closed (safe). This is ugly, but resolves top crashers in the
// wild.
try {
// Ignore all invalid URLs, regardless of what the intent was.
if (!intentHasValidUrl(intent)) {
return true;
}
// Determine if this intent came from a trustworthy source (either Chrome or Google
// first party applications).
boolean isInternal = isIntentChromeOrFirstParty(intent, context);
// "Open new incognito tab" is currently limited to Chrome or first parties.
if (!isInternal
&& IntentUtils.safeGetBooleanExtra(
intent, EXTRA_OPEN_NEW_INCOGNITO_TAB, false)
&& (getPendingIncognitoUrl() == null
|| !getPendingIncognitoUrl().equals(intent.getDataString()))) {
return true;
}
// Now if we have an empty URL and the intent was ACTION_MAIN,
// we are pretty sure it is the launcher calling us to show up.
// We can safely ignore the screen state.
String url = getUrlFromIntent(intent);
if (url == null && Intent.ACTION_MAIN.equals(intent.getAction())) {
return false;
}
// Ignore all intents that specify a Chrome internal scheme if they did not come from
// a trustworthy source.
String scheme = getSanitizedUrlScheme(url);
if (!isInternal && scheme != null
&& (intent.hasCategory(Intent.CATEGORY_BROWSABLE)
|| intent.hasCategory(Intent.CATEGORY_DEFAULT)
|| intent.getCategories() == null)) {
String lowerCaseScheme = scheme.toLowerCase(Locale.US);
if ("chrome".equals(lowerCaseScheme) || "chrome-native".equals(lowerCaseScheme)
|| "about".equals(lowerCaseScheme)) {
// Allow certain "safe" internal URLs to be launched by external
// applications.
String lowerCaseUrl = url.toLowerCase(Locale.US);
if ("about:blank".equals(lowerCaseUrl)
|| "about://blank".equals(lowerCaseUrl)) {
return false;
}
Log.w(TAG, "Ignoring internal Chrome URL from untrustworthy source.");
return true;
}
}
// We must check for screen state at this point.
// These might be slow.
boolean internalOrVisible = isInternal || isIntentUserVisible(context);
return !internalOrVisible;
} catch (Throwable t) {
return true;
}
}
示例12: initSplash
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void initSplash(ConfigSplash configSplash) {
if (!isTaskRoot()) {
final Intent intent = getIntent();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) {
Log.w(LOG_TAG, "Main Activity is not the root. Finishing Main Activity instead of launching.");
finish();
return;
}
}
/* you don't have to override every property */
//Customize Circular Reveal
configSplash.setBackgroundColor(R.color.lightbluesplash); //any color you want form colors.xml
configSplash.setAnimCircularRevealDuration(1000); //int ms
configSplash.setRevealFlagX(Flags.REVEAL_RIGHT); //or Flags.REVEAL_LEFT
configSplash.setRevealFlagY(Flags.REVEAL_BOTTOM); //or Flags.REVEAL_TOP
//Choose LOGO OR PATH; if you don't provide String value for path it's logo by default
//Customize Logo
configSplash.setLogoSplash(R.drawable.cglogo); //or any other drawable
configSplash.setAnimLogoSplashDuration(1000); //int ms
configSplash.setAnimLogoSplashTechnique(Techniques.FadeIn); //choose one form Techniques (ref: https://github.com/daimajia/AndroidViewAnimations)
//Customize Path
// configSplash.setPathSplash(Constants.DROID_LOGO); //set path String
configSplash.setOriginalHeight(400); //in relation to your svg (path) resource
configSplash.setOriginalWidth(400); //in relation to your svg (path) resource
configSplash.setAnimPathStrokeDrawingDuration(1000);
configSplash.setPathSplashStrokeSize(3); //I advise value be <5
configSplash.setPathSplashStrokeColor(R.color.lightbluesplash); //any color you want form colors.xml
configSplash.setAnimPathFillingDuration(1000);
configSplash.setPathSplashFillColor(R.color.white); //path object filling color
//Customize Title
configSplash.setTitleSplash(getResources().getString(R.string.charetakergames));
configSplash.setTitleTextColor(R.color.white);
configSplash.setTitleTextSize(20f); //float value
configSplash.setAnimTitleDuration(0);
configSplash.setAnimTitleTechnique(Techniques.FadeIn);
configSplash.setTitleFont("fonts/grobold.ttf"); //provide string to your font located in assets/fonts/
}