Activity getComponentName - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:getComponentName, startActivity, getPackageManager
                        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);
            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; 

7
CodeRank
This code example shows how to use the following methods:getComponentName, getPackageManager, getResources
	public void testOrientation() throws NameNotFoundException { 
		Activity currentActivity = solo.getCurrentActivity();
 
		/// Method 1: Assert it is currently in portrait mode. 
		assertEquals("ScriptActivity not in Portrait mode!", Configuration.ORIENTATION_PORTRAIT, currentActivity
				.getResources().getConfiguration().orientation);
 
		/// Method 2: Retrieve info about Activity as collected from AndroidManifest.xml 
		// https://developer.android.com/reference/android/content/pm/ActivityInfo.html 
		PackageManager packageManager = currentActivity.getPackageManager();
		ActivityInfo activityInfo = packageManager.getActivityInfo(currentActivity.getComponentName(),
				PackageManager.GET_ACTIVITIES);
 
		// Note that the activity is _indeed_ rotated on your device/emulator! 
		// Robotium can _force_ the activity to be in landscape mode (and so could we, programmatically) 
		solo.setActivityOrientation(Solo.LANDSCAPE); 
		solo.sleep(200); 
 
		assertEquals(ScriptActivity.class.getSimpleName() + " not set to be in portrait mode in AndroidManifest.xml!",
				ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, activityInfo.screenOrientation);
7
CodeRank

Related Activity getComponentName Questions & Answers:

Other Activity getComponentName Examples

8:					.getActionView();
9:			searchView.setSearchableInfo(searchManager
10:					.getSearchableInfo(getComponentName()));
11:	
12:			return super.onCreateOptionsMenu(menu);

Read More

13:	         0,      // Unique item ID (none)
14:	         0,      // Order for the items (none)
15:	         this.getComponentName(),   // The current activity name
16:	         null,   // Specific items to place first (none)
17:	         intent, // Intent created above that describes our requirements

Read More

getComponentName Method Overview
Returns complete component name of this activity.
See Code Examples for other Android Activity Methods: