Java Code Examples for android.content.Intent.setClassName()

The following are Jave code examples for showing how to use setClassName() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Liteframework   File: PackageUtil.java   View Source Code Vote up 7 votes
/**
 * 打开已安装应用的详情
 */
public static void goToInstalledAppDetails(Context context, String packageName) {
    Intent intent = new Intent();
    int sdkVersion = Build.VERSION.SDK_INT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.fromParts("package", packageName, null));
    } else {
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        intent.putExtra((sdkVersion == Build.VERSION_CODES.FROYO ? "pkg"
                : "com.android.settings.ApplicationPkgName"), packageName);
    }
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example 2
Project: buildAPKsApps   File: MainMenu.java   View Source Code Vote up 7 votes
@Override
public void onClick(View v) {
	Intent intent = new Intent();
	switch (v.getId()) {
	case R.id.mintest:
    	intent.setClassName("net.fercanet.LNM", "net.fercanet.LNM.Game");
    	intent.putExtra("omt", true);
    	startActivity(intent);
	break;
	case R.id.training:	
    	intent.setClassName("net.fercanet.LNM", "net.fercanet.LNM.Game");
    	intent.putExtra("omt", false);
    	startActivity(intent);
	break;
	case R.id.hof:	
    	intent.setClassName("net.fercanet.LNM", "net.fercanet.LNM.Hof");
    	startActivity(intent);

   	break;
	case R.id.endgame:	
    	moveTaskToBack(true);

   	break;
	}
}
 
Example 3
Project: container   File: BroadcastIntent.java   View Source Code Vote up 7 votes
private Intent handleInstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName component = shortcut.resolveActivity(VirtualCore.getPM());
        if (component != null) {
            String pkg = component.getPackageName();
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
            newShortcutIntent.putExtra("_VA_|_intent_", shortcut);
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
            newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
            intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);

            Intent.ShortcutIconResource icon = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
            if (icon != null && !TextUtils.equals(icon.packageName, getHostPkg())) {
                try {
                    Resources resources = VirtualCore.get().getResources(pkg);
                    if (resources != null) {
                        int resId = resources.getIdentifier(icon.resourceName, "drawable", pkg);
                        if (resId > 0) {
                            Drawable iconDrawable = resources.getDrawable(resId);
                            Bitmap newIcon = BitmapUtils.drawableToBitmap(iconDrawable);
                            if (newIcon != null) {
                                intent.removeExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
                                intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newIcon);
                            }
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return intent;
}
 
Example 4
Project: FlickLauncher   File: ApplicationInfo.java   View Source Code Vote up 7 votes
public static void showInstalledAppDetails(Context context, String packageName) {
    Intent intent = new Intent();
    final int apiLevel = Build.VERSION.SDK_INT;
    if (apiLevel >= 9) { // above 2.3
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts(SCHEME, packageName, null);
        intent.setData(uri);
    } else { // below 2.3
        final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22
                : APP_PKG_NAME_21);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName(APP_DETAILS_PACKAGE_NAME,
                APP_DETAILS_CLASS_NAME);
        intent.putExtra(appPkgName, packageName);
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example 5
Project: remoter   File: RemoterClientToAidlServerTest.java   View Source Code Vote up 6 votes
@Before
public void setup() throws InterruptedException {
    synchronized (objectLock) {
        Intent remoterServiceIntent = new Intent(INTENT_AIDL_SERVICE);
        remoterServiceIntent.setClassName("util.remoter.aidlservice", INTENT_AIDL_SERVICE);

        mActivityRule.getActivity().startService(remoterServiceIntent);
        mActivityRule.getActivity().bindService(remoterServiceIntent, serviceConnection, 0);

        objectLock.wait();
        Log.i(TAG, "Service connected");
    }
}
 
Example 6
Project: ReplyMessage   File: JumpPermissionManagement.java   View Source Code Vote up 6 votes
/**
 * 应用信息界面
 * @param activity
 */
public static void ApplicationInfo(Activity activity){
    Intent localIntent = new Intent();
    localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (Build.VERSION.SDK_INT >= 9) {
        localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
        localIntent.setData(Uri.fromParts("package", activity.getPackageName(), null));
    } else if (Build.VERSION.SDK_INT <= 8) {
        localIntent.setAction(Intent.ACTION_VIEW);
        localIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        localIntent.putExtra("com.android.settings.ApplicationPkgName", activity.getPackageName());
    }
    activity.startActivity(localIntent);
}
 
Example 7
Project: HeadlineNews   File: ActivityUtils.java   View Source Code Vote up 6 votes
/**
 * 判断是否存在Activity
 *
 * @param packageName 包名
 * @param className   activity全路径类名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isActivityExists(@NonNull final String packageName,
                                       @NonNull final String className) {
    Intent intent = new Intent();
    intent.setClassName(packageName, className);
    return !(Utils.getContext().getPackageManager().resolveActivity(intent, 0) == null ||
            intent.resolveActivity(Utils.getContext().getPackageManager()) == null ||
            Utils.getContext().getPackageManager().queryIntentActivities(intent, 0).size() == 0);
}
 
Example 8
Project: astrobee_android   File: MainActivity.java   View Source Code Vote up 6 votes
/**
 * Bind this Activity to Android-ROS bridge service
 */
private void doBindService() {
    Intent intent = new Intent();
    intent.setClassName(GUESTSCIENCE_SERVICE_CONTEXT, GUESTSCIENCE_SERVICE_CLASSNAME);
    bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
    mIsBound = true;
    mTextCommStatus.setText("Comm Status: Binded");
    Log.i(LOGTAG, "BINDED to SERVICE!");
}
 
Example 9
Project: keepass2android   File: CaptureActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  switch (item.getItemId()) {
    case R.id.menu_settings:
      intent.setClassName(this, PreferencesActivity.class.getName());
      startActivity(intent);
      break;
    default:
      return super.onOptionsItemSelected(item);
  }
  return true;
}
 
Example 10
Project: container   File: VAccountManagerService.java   View Source Code Vote up 6 votes
void bind() {
	Log.v(TAG, "initiating bind to authenticator type " + mAuthenticatorInfo.desc.type);
	Intent intent = new Intent();
	intent.setAction(AccountManager.ACTION_AUTHENTICATOR_INTENT);
	intent.setClassName(mAuthenticatorInfo.serviceInfo.packageName, mAuthenticatorInfo.serviceInfo.name);
	intent.putExtra("_VA_|_user_id_", mUserId);

	if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) {
		Log.d(TAG, "bind attempt failed for " + toDebugString());
		onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "bind failure");
	}
}
 
Example 11
Project: Say_it   File: MainActivity.java   View Source Code Vote up 6 votes
private void ifHuaweiAlert() {
    final SharedPreferences settings = getSharedPreferences("ProtectedApps", MODE_PRIVATE);
    final String saveIfSkip = "skipProtectedAppsMessage";
    boolean skipMessage = settings.getBoolean(saveIfSkip, false);
    if (!skipMessage) {
        final SharedPreferences.Editor editor = settings.edit();
        Intent intent = new Intent();
        intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");
        if (isCallable(intent)) {
            final AppCompatCheckBox dontShowAgain = new AppCompatCheckBox(this);
            dontShowAgain.setText(R.string.Do_not_show_again);
            dontShowAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    editor.putBoolean(saveIfSkip, isChecked);
                    editor.apply();
                }
            });

            new AlertDialog.Builder(this)
                    .setTitle("Huawei Protected Apps")
                    .setMessage(String.format("%s requires to be enabled in 'Protected Apps' to send notifications.%n", getString(R.string.app_name)))
                    .setView(dontShowAgain)
                    .setPositiveButton("Protected Apps", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            huaweiProtectedApps();
                        }
                    })
                    .setNegativeButton("Cancel", null)
                    .show();
        } else {
            editor.putBoolean(saveIfSkip, true);
            editor.apply();
        }
    }
}
 
Example 12
Project: boohee_v5.6   File: d.java   View Source Code Vote up 6 votes
public void run() {
    if (!MiPushClient.shouldUseMIUIPush(this.a) && 1 == a.a(this.a).m()) {
        try {
            List<PackageInfo> installedPackages = this.a.getPackageManager()
                    .getInstalledPackages(4);
            if (installedPackages != null) {
                for (PackageInfo packageInfo : installedPackages) {
                    ServiceInfo[] serviceInfoArr = packageInfo.services;
                    if (serviceInfoArr != null) {
                        for (ServiceInfo serviceInfo : serviceInfoArr) {
                            if (serviceInfo.exported && serviceInfo.enabled && ("com.xiaomi" +
                                    ".mipush.sdk.PushMessageHandler").equals(serviceInfo
                                    .name) && !this.a.getPackageName().equals(serviceInfo
                                    .packageName)) {
                                try {
                                    Thread.sleep(((long) ((Math.random() * PathListView
                                            .ZOOM_X2) + PathListView.NO_ZOOM)) * 1000);
                                } catch (InterruptedException e) {
                                }
                                Intent intent = new Intent();
                                intent.setClassName(serviceInfo.packageName, serviceInfo.name);
                                intent.setAction("com.xiaomi.mipush.sdk.WAKEUP");
                                this.a.startService(intent);
                            }
                        }
                        continue;
                    }
                }
            }
        } catch (Throwable th) {
        }
    }
}
 
Example 13
Project: TIIEHenry-Android-SDK   File: LocationUtil.java   View Source Code Vote up 6 votes
/**
 * 强制打开GPS
 * 
 * @param context
 */
public static void forceOpenGPS(Context context) {
	// 4.0++
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
		Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
		intent.putExtra("enabled", true);
		context.sendBroadcast(intent);

		String provider = Settings.Secure.getString(
				context.getContentResolver(),
				Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
		if (!provider.contains("gps")) { // if gps is disabled
			final Intent poke = new Intent();
			poke.setClassName("com.android.settings",
					"com.android.settings.widget.SettingsAppWidgetProvider");
			poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
			poke.setData(Uri.parse("3"));
			context.sendBroadcast(poke);
		}
	} else {
		Intent GPSIntent = new Intent();
		GPSIntent.setClassName("com.android.settings",
				"com.android.settings.widget.SettingsAppWidgetProvider");
		GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
		GPSIntent.setData(Uri.parse("custom:3"));
		try {
			PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
		} catch (CanceledException e) {
		}
	}
}
 
Example 14
Project: Leanplum-Android-SDK   File: LeanplumPushReceiver.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
  try {
    if (intent == null) {
      Log.e("Received a null intent.");
      return;
    }
    // Parse manifest and pull metadata which contains client broadcast receiver class.
    String receiver = LeanplumManifestHelper.parseNotificationMetadata();
    // If receiver isn't found we will open up notification with default activity
    if (receiver == null) {
      Log.d("Custom broadcast receiver class not set, using default one.");
      LeanplumPushService.openNotification(context, intent);
    } else {
      Log.d("Custom broadcast receiver class found, using it to handle push notifications.");
      // Forward Intent to a client broadcast receiver.
      Intent forwardIntent = new Intent();
      // Add action to be able to differentiate between multiple intents.
      forwardIntent.setAction(LeanplumPushService.LEANPLUM_NOTIFICATION);
      forwardIntent.setClassName(context, receiver);
      forwardIntent.putExtras(intent.getExtras());
      context.sendBroadcast(forwardIntent);
    }
  } catch (Throwable t) {
    Util.handleException(t);
  }
}
 
Example 15
Project: LJFramework   File: ActivityUtils.java   View Source Code Vote up 6 votes
/**
 * 判断是否存在Activity
 *
 * @param packageName 包名
 * @param className activity全路径类名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isActivityExists(String packageName, String className) {
    Intent intent = new Intent();
    intent.setClassName(packageName, className);
    PackageManager packageManager = ContextUtils.getContext()
                                                .getPackageManager();
    return !(packageManager.resolveActivity(intent, 0) == null ||
                     intent.resolveActivity(packageManager) == null ||
                     packageManager.queryIntentActivities(intent, 0)
                                   .isEmpty());
}
 
Example 16
Project: weex-3d-map   File: ResultHandler.java   View Source Code Vote up 5 votes
final void searchBookContents(String isbnOrUrl) {
  Intent intent = new Intent(Intents.SearchBookContents.ACTION);
  intent.setClassName(activity, SearchBookContentsActivity.class.getName());
  putExtra(intent, Intents.SearchBookContents.ISBN, isbnOrUrl);
  launchIntent(intent);
}
 
Example 17
Project: NoteBuddy   File: SetupActivity.java   View Source Code Vote up 5 votes
/**
 * Attempts to sign in with the login form.
 * If there are form errors, the errors are presented
 * and no actual login attempt is made.
 */
private void attemptRegistration() {

    m_username.setError(null);
    m_passwordView.setError(null);

    String username = m_username.getText().toString();
    String password = m_passwordView.getText().toString();
    String passwordCheck = m_passwordCheckView.getText().toString();

    boolean cancel = false;
    View focusView = null;

    if(!PasswordValidator.isPasswordValid(password)) {
        m_passwordView.setError(getString(R.string.error_invalid_password));
        focusView = m_passwordView;
        cancel = true;
    }
    if(!password.equals(passwordCheck)) {
        m_passwordCheckView.setError(getString(R.string.error_invalid_password_check));
        focusView = m_passwordCheckView;
        cancel = true;
    }
    if(TextUtils.isEmpty(username)) {
        m_username.setError(getString(R.string.error_field_required));
        focusView = m_username;
        cancel = true;
    } else if(!UsernameValidator.isUsernameValid(username)) {
        m_username.setError(getString(R.string.error_invalid_username));
        focusView = m_username;
        cancel = true;
    }
    if(cancel) {
        focusView.requestFocus();
    } else {
        try {
            KeyValueDB.setUsername(m_context, username);
            SaltHandler.setSalt(m_context);
            KeyValueDB.setVerificationPasswordHash(m_context, LoginHashCreator.getLoginHash(m_context, password));
            showProgress(true);
            Intent intent = new Intent();
            intent.setClassName(m_context, PACKAGE_NAME + "." + NOTES_ACTIVITY);
            intent.putExtra(LoginActivity.KEY_PASSWORD, password);
            startActivity(intent);
            finish();
        } catch (Exception e) {
            Toast.makeText(getApplicationContext(), getString(R.string.error_cannot_save) + ". ", Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example 18
Project: boohee_v5.6   File: h.java   View Source Code Vote up 5 votes
public void a() {
    PackageInfo packageInfo;
    String str = "com.tencent.mobileqq";
    try {
        packageInfo = this.a.getContext().getPackageManager().getPackageInfo(str, 0);
    } catch (Throwable th) {
        this.a.finish();
        if (this.c != null) {
            this.c.onFailed(new TencentSSOClientNotInstalledException());
            return;
        }
        return;
    }
    if (packageInfo == null) {
        this.a.finish();
        if (this.c != null) {
            this.c.onFailed(new TencentSSOClientNotInstalledException());
            return;
        }
        return;
    }
    Intent intent = new Intent();
    intent.setClassName(str, "com.tencent.open.agent.AgentActivity");
    if (this.a.getContext().getPackageManager().resolveActivity(intent, 0) == null) {
        this.a.finish();
        if (this.c != null) {
            this.c.onFailed(new TencentSSOClientNotInstalledException());
            return;
        }
        return;
    }
    Bundle bundle = new Bundle();
    bundle.putString("scope", this.e);
    bundle.putString(Constants.PARAM_CLIENT_ID, this.d);
    bundle.putString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF);
    bundle.putString("need_pay", "1");
    intent.putExtra(Constants.KEY_PARAMS, bundle);
    intent.putExtra(Constants.KEY_REQUEST_CODE, this.b);
    intent.putExtra(Constants.KEY_ACTION, SystemUtils.ACTION_LOGIN);
    try {
        this.a.startActivityForResult(intent, this.b);
    } catch (Throwable th2) {
        this.a.finish();
        if (this.c != null) {
            this.c.onFailed(th2);
        }
    }
}
 
Example 19
Project: GravityBox   File: NetworkModeTile.java   View Source Code Vote up 5 votes
@Override
public Intent getSettingsIntent() {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName("com.android.phone", "com.android.phone.Settings");
    return intent;
}
 
Example 20
Project: RLibrary   File: ActivityUtils.java   View Source Code Vote up 4 votes
/**
 * 判断是否存在Activity
 *
 * @param context     上下文
 * @param packageName 包名
 * @param className   activity全路径类名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isActivityExists(Context context, String packageName, String className) {
    Intent intent = new Intent();
    intent.setClassName(packageName, className);
    return !(context.getPackageManager().resolveActivity(intent, 0) == null ||
            intent.resolveActivity(context.getPackageManager()) == null ||
            context.getPackageManager().queryIntentActivities(intent, 0).size() == 0);
}