Java Code Examples for android.app.Activity#getComponentName()

The following examples show how to use android.app.Activity#getComponentName() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/** @hide */
public AssistStructure(Activity activity, boolean forAutoFill, int flags) {
    mHaveData = true;
    mActivityComponent = activity.getComponentName();
    mFlags = flags;
    ArrayList<ViewRootImpl> views = WindowManagerGlobal.getInstance().getRootViews(
            activity.getActivityToken());
    for (int i=0; i<views.size(); i++) {
        ViewRootImpl root = views.get(i);
        if (root.getView() == null) {
            Log.w(TAG, "Skipping window with dettached view: " + root.getTitle());
            continue;
        }
        mWindowNodes.add(new WindowNode(this, root, forAutoFill, flags));
    }
}
 
Example 2
Source Project: springreplugin   File: PluginContainers.java    License: Apache License 2.0 6 votes vote down vote up
final void handleCreate(String plugin, Activity activity, String container) {
    ComponentName cn = activity.getComponentName();
    if (cn != null) {
        container = cn.getClassName();
    }
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "PACM: activity created h=" + activity.hashCode() + " class=" + activity.getClass().getName() + " container=" + container);
    }
    synchronized (mLock) {
        HashMap<String, ActivityState> map = mStates;
        ActivityState state = map.get(container);
        if (state != null) {
            state.create(plugin, activity);
        }
    }
}
 
Example 3
Source Project: springreplugin   File: PluginContainers.java    License: Apache License 2.0 6 votes vote down vote up
final void handleDestroy(Activity activity) {
    String container = null;
    //
    ComponentName cn = activity.getComponentName();
    if (cn != null) {
        container = cn.getClassName();
    }
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "PACM: activity destroy h=" + activity.hashCode() + " class=" + activity.getClass().getName() + " container=" + container);
    }
    if (container == null) {
        return;
    }
    synchronized (mLock) {
        HashMap<String, ActivityState> map = mStates;
        ActivityState state = map.get(container);
        if (state != null) {
            state.removeRef(activity);
        }
    }
}
 
Example 4
Source Project: DoraemonKit   File: SystemUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 是否是系统main activity
 *
 * @return boolean
 */
public static boolean isMainLaunchActivity(Activity activity) {
    PackageManager packageManager = activity.getApplication().getPackageManager();
    Intent intent = packageManager.getLaunchIntentForPackage(activity.getPackageName());
    if (intent == null) {
        return false;
    }
    ComponentName launchComponentName = intent.getComponent();
    ComponentName componentName = activity.getComponentName();
    if (launchComponentName != null && componentName.toString().equals(launchComponentName.toString())) {
        return true;
    }
    return false;
}
 
Example 5
/**
 * Notify the host application a download should be done, or that the data
 * should be streamed if a streaming viewer is available.
 * 
 * @param activity
 *            Activity requesting the download.
 * @param url
 *            The full url to the content that should be downloaded
 * @param userAgent
 *            User agent of the downloading application.
 * @param contentDisposition
 *            Content-disposition http header, if present.
 * @param mimetype
 *            The mimetype of the content reported by the server
 * @param privateBrowsing
 *            If the request is coming from a private browsing tab.
 */
public static void onDownloadStart(Activity activity, String url, String userAgent,
		String contentDisposition, String mimetype, boolean privateBrowsing) {
	// if we're dealing wih A/V content that's not explicitly marked
	// for download, check if it's streamable.
	if (contentDisposition == null
			|| !contentDisposition.regionMatches(true, 0, "attachment", 0, 10)) {
		// query the package manager to see if there's a registered handler
		// that matches.
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setDataAndType(Uri.parse(url), mimetype);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		ResolveInfo info = activity.getPackageManager().resolveActivity(intent,
				PackageManager.MATCH_DEFAULT_ONLY);
		if (info != null) {
			ComponentName myName = activity.getComponentName();
			// If we resolved to ourselves, we don't want to attempt to
			// load the url only to try and download it again.
			if (!myName.getPackageName().equals(info.activityInfo.packageName)
					|| !myName.getClassName().equals(info.activityInfo.name)) {
				// someone (other than us) knows how to handle this mime
				// type with this scheme, don't download.
				try {
					activity.startActivity(intent);
					return;
				} catch (ActivityNotFoundException ex) {
					// Best behavior is to fall back to a download in this
					// case
				}
			}
		}
	}
	onDownloadStartNoStream(activity, url, userAgent, contentDisposition, mimetype,
			privateBrowsing);
}
 
Example 6
private String fetchPluginByPitActivity(Activity a) {
    PluginContainers.ActivityState state = null;
    if (a.getComponentName() != null) {
        state = mPluginMgr.mClient.mACM.lookupByContainer(a.getComponentName().getClassName());
    }

    if (state != null) {
        return state.plugin;
    } else {
        return null;
    }
}
 
Example 7
Source Project: Recovery   File: RecoveryStore.java    License: Apache License 2.0 5 votes vote down vote up
ComponentName getBaseActivity() {
    for (WeakReference<Activity> activityWeakReference : mRunningActivities) {
        if (activityWeakReference == null)
            continue;
        Activity tmpActivity = activityWeakReference.get();
        if (tmpActivity == null)
            continue;
        return tmpActivity.getComponentName();
    }
    return null;
}
 
Example 8
private static ComponentName getComponentName() {
    if (!ApplicationStatus.hasVisibleActivities()) return null;

    Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    if (activity instanceof ChromeTabbedActivity) {
        return activity.getComponentName();
    }

    return null;
}