List of usage examples for android.content ComponentName getShortClassName
public String getShortClassName()
From source file:Main.java
/** * @param context//from w w w .java 2 s .com * @return String * @throws * @Title: getActivityName * @Description: TODO */ public static String getActivityName(Context context) { collectUtilContext = context; if (collectUtilContext == null) { return ""; } ActivityManager am = (ActivityManager) collectUtilContext .getSystemService(collectUtilContext.ACTIVITY_SERVICE); if (checkPermission(collectUtilContext, "android.permission.GET_TASKS")) { ComponentName cn = am.getRunningTasks(1).get(0).topActivity; return cn.getShortClassName(); } return ""; }
From source file:Main.java
private static String toComponentName(ComponentName cn) { if (cn == null) return null; else//from w w w . ja va2 s . com return cn.getPackageName() + "/" + cn.getShortClassName(); }
From source file:bolts.MeasurementEvent.java
private static Bundle getApplinkLogData(Context context, String eventName, Bundle appLinkData, Intent applinkIntent) {// w ww . j ava 2 s. c o m Bundle logData = new Bundle(); ComponentName resolvedActivity = applinkIntent.resolveActivity(context.getPackageManager()); if (resolvedActivity != null) { logData.putString("class", resolvedActivity.getShortClassName()); } if (APP_LINK_NAVIGATE_OUT_EVENT_NAME.equals(eventName)) { if (resolvedActivity != null) { logData.putString("package", resolvedActivity.getPackageName()); } if (applinkIntent.getData() != null) { logData.putString("outputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("outputURLScheme", applinkIntent.getScheme()); } } else if (APP_LINK_NAVIGATE_IN_EVENT_NAME.equals(eventName)) { if (applinkIntent.getData() != null) { logData.putString("inputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("inputURLScheme", applinkIntent.getScheme()); } } for (String key : appLinkData.keySet()) { Object o = appLinkData.get(key); if (o instanceof Bundle) { for (String subKey : ((Bundle) o).keySet()) { String logValue = objectToJSONString(((Bundle) o).get(subKey)); if (key.equals("referer_app_link")) { if (subKey.equalsIgnoreCase("url")) { logData.putString("refererURL", logValue); continue; } else if (subKey.equalsIgnoreCase("app_name")) { logData.putString("refererAppName", logValue); continue; } else if (subKey.equalsIgnoreCase("package")) { logData.putString("sourceApplication", logValue); continue; } } logData.putString(key + "/" + subKey, logValue); } } else { String logValue = objectToJSONString(o); if (key.equals("target_url")) { Uri targetURI = Uri.parse(logValue); logData.putString("targetURL", targetURI.toString()); logData.putString("targetURLHost", targetURI.getHost()); continue; } logData.putString(key, logValue); } } return logData; }
From source file:com.wbtech.common.CommonUtil.java
/** * ??activity??//from ww w .jav a 2 s. c o m * @param context * @return */ public static String getActivityName(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (checkPermissions(context, "android.permission.GET_TASKS")) { ComponentName cn = am.getRunningTasks(1).get(0).topActivity; return cn.getShortClassName(); } else { if (UmsConstants.DebugMode) { Log.e("lost permission", "android.permission.GET_TASKS"); } return null; } }
From source file:org.mythdroid.remote.NavRemote.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); gesture = PreferenceManager.getDefaultSharedPreferences(this).getString("tvDefaultStyle", "") //$NON-NLS-1$ //$NON-NLS-2$ .equals(Messages.getString("NavRemote.0")); // Gesture //$NON-NLS-1$ setupViews(gesture);/*from w ww .j a v a 2 s . co m*/ listenToGestures(gesture); if (getIntent().hasExtra(Extras.GUIDE.toString())) jumpGuide = true; String calledBy = null; ComponentName caller = getCallingActivity(); if (caller != null) calledBy = caller.getShortClassName(); if (calledBy != null) { if (calledBy.endsWith(".TVRemote")) //$NON-NLS-1$ calledByTVRemote = true; else if (calledBy.endsWith(".MusicRemote")) //$NON-NLS-1$ calledByMusicRemote = true; } calledByRemote = calledByTVRemote || calledByMusicRemote; }