Example usage for android.content ComponentName ComponentName

List of usage examples for android.content ComponentName ComponentName

Introduction

In this page you can find the example usage for android.content ComponentName ComponentName.

Prototype

private ComponentName(String pkg, Parcel in) 

Source Link

Usage

From source file:de.Maxr1998.xposed.maxlock.ui.settings.SettingsFragment.java

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    super.onPreferenceTreeClick(preferenceScreen, preference);
    if (preference == findPreference(Common.LOCKING_TYPE_SETTINGS)) {
        launchFragment(new LockingTypeSettingsFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.LOCKING_UI_SETTINGS)) {
        launchFragment(new LockingUISettingsFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.LOCKING_OPTIONS)) {
        PREFS.edit().putBoolean(Common.ENABLE_LOGGING, PREFS.getBoolean(Common.ENABLE_PRO, false)).apply();
        launchFragment(new LockingOptionsFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.IIMOD_OPTIONS)) {
        // Setup remain timer
        long timer = PREFS.getInt(Common.IMOD_DELAY_GLOBAL, 600000)
                - (System.currentTimeMillis() - PREFS.getLong(Common.IMOD_LAST_UNLOCK_GLOBAL, 0));
        if (timer < 0) {
            timer = 0L;//from w w w .  j  ava2 s . com
        }
        PREFS.edit().putInt(Common.IMOD_REMAIN_TIMER_GLOBAL, (int) timer).apply();
        launchFragment(new LockingIntikaFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.CHOOSE_APPS)) {
        launchFragment(new AppListFragment(), true, this);
        return true;
    } else if (preference == findPreference(Common.HIDE_APP_FROM_LAUNCHER)
            && preference instanceof CheckBoxPreference) {
        CheckBoxPreference hideApp = (CheckBoxPreference) preference;
        if (hideApp.isChecked()) {
            Toast.makeText(getActivity(), R.string.reboot_required, Toast.LENGTH_SHORT).show();
            ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
            getActivity().getPackageManager().setComponentEnabledSetting(componentName,
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        } else {
            ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
            getActivity().getPackageManager().setComponentEnabledSetting(componentName,
                    PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        }
    } else if (preference == findPreference(Common.USE_DARK_STYLE)
            || preference == findPreference(Common.ENABLE_PRO)) {
        ((SettingsActivity) getActivity()).restart();
        return true;
    } else if (preference == findPreference(Common.UNINSTALL)) {
        if (!isDeviceAdminActive()) {
            Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
            intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin);
            startActivity(intent);
        } else {
            devicePolicyManager.removeActiveAdmin(deviceAdmin);
        }
        return true;
    }
    return false;
}

From source file:com.bubblegum.traceratops.app.ui.activities.MainActivity.java

private void confirmTrustAgent(String packageName) {
    String trustPackageName = packageName.concat(".trust");
    String confirmActivityName = "com.bubblegum.traceratops.trust.ui.ConfirmationActivity";
    ComponentName trustComponent = new ComponentName(trustPackageName, confirmActivityName);
    Intent confirmIntent = new Intent();
    confirmIntent.setComponent(trustComponent);
    startActivity(confirmIntent);//from  w  ww  .  ja va 2 s  .  c o m
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case SETTINGS_REQUEST_CODE:
        AppWidgetManager man = AppWidgetManager.getInstance(this);
        if (man != null) {
            int[] ids = man.getAppWidgetIds(new ComponentName(mAppContext, HomeScreenWidgetProvider.class));
            Intent updateIntent = new Intent();
            updateIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
            updateIntent.putExtra(HomeScreenWidgetProvider.WIDGET_IDS_KEY, ids);
            this.sendBroadcast(updateIntent);
        }//w  ww  .  ja v a 2s  . co  m

        if (resultCode == RESULT_CONNECT_GOOGLE_CODE) {
            mTaskFragment.connectPlayServices(findViewById(VIEW_ID_POPUPS));
        }
        break;

    case PURCHASE_REQUEST_CODE:
        if (resultCode == RESULT_OK) {
            String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString("productId");
                if (sku.equals(utils.SKU_DONATE)) {
                    PrefUtils.setUserDonated(this, true);
                    Toast.makeText(this, R.string.toast_purchase_thanks, Toast.LENGTH_LONG).show();
                    mAdView.destroy();
                    LinearLayout adLayout = (LinearLayout) findViewById(R.id.adLayout);
                    adLayout.setVisibility(View.GONE);
                }
            } catch (JSONException e) {
                Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT).show();
            }
        }
        break;

    case BlindGameActivity.REQUEST_CODE:
        /*if (resultCode == RESULT_OK){
           selectItem(DrawerPosition.GAMES, data.getExtras());
        } else selectItem(DrawerPosition.GAMES, null);*/
        break;

    case 1001:
        if (resultCode == RESULT_OK) {
            mTaskFragment.connectPlayServices(findViewById(VIEW_ID_POPUPS));
        } else {
            PrefUtils.setRefusedGoogle(this, true);
        }
        break;
    }
}

From source file:org.ametro.app.ApplicationEx.java

public void changeBootCompletedReceiverState(boolean enabled) {
    PackageManager manager = getPackageManager();
    ComponentName name = new ComponentName(this, BootCompletedReceiver.class);
    int state = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
    manager.setComponentEnabledSetting(name, state, PackageManager.DONT_KILL_APP);
}

From source file:de.hackerspacebremen.fragments.StatusFragment.java

private void updateAppWidget(SpaceData data) {
    SharedPreferences dataPersistence = getActivity().getSharedPreferences(Constants.SPACE_DATA_PERSISTENCE,
            Context.MODE_PRIVATE);
    Editor editor = dataPersistence.edit();
    editor.putBoolean(Constants.SPACE_OPEN_DATA_KEY, data.isSpaceOpen());
    editor.commit();//from   w  w  w .j  a  va2 s  .  c om

    RemoteViews remoteViews = new RemoteViews(getActivity().getPackageName(), R.layout.appwidget);
    remoteViews.setViewVisibility(R.id.indicatorImage, View.VISIBLE);
    remoteViews.setViewVisibility(R.id.errorText, View.GONE);

    if (data.isSpaceOpen()) {
        remoteViews.setImageViewResource(R.id.indicatorImage, R.drawable.banner);
    } else {
        remoteViews.setImageViewResource(R.id.indicatorImage, R.drawable.banner_blur);
    }

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
    ComponentName componentName = new ComponentName(getActivity(), HackerspaceWidgetProvider.class);
    appWidgetManager.updateAppWidget(componentName, remoteViews);
}

From source file:ch.fixme.status.Widget.java

public static void UpdateAllWidgets(final Context ctxt) {
    AppWidgetManager man = AppWidgetManager.getInstance(ctxt);
    int[] ids = man.getAppWidgetIds(new ComponentName(ctxt, Widget.class));
    Intent ui = new Intent();
    ui.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    ui.putExtra(Widget.WIDGET_IDS, ids);
    ui.putExtra(Widget.WIDGET_FORCE, true);
    ctxt.sendBroadcast(ui);/*from  w ww.ja v  a 2  s  .co  m*/
}

From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        Log.w(TAG, "Restored state");
        mOriginalSettings = savedInstanceState.getBundle(ORIGINAL_SETTINGS_NAME);
    } else {//from   w w w .  j  a v  a  2  s.c o  m
        mOriginalSettings = new Bundle();
    }

    mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName());
    mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    Intent intent = getIntent();
    String action = intent.getAction();
    Log.d(TAG, "ByodHelperActivity.onCreate: " + action);

    // we are explicitly started by {@link DeviceAdminTestReceiver} after a successful provisioning.
    if (action.equals(ACTION_PROFILE_PROVISIONED)) {
        // Jump back to CTS verifier with result.
        Intent response = new Intent(ACTION_PROFILE_OWNER_STATUS);
        response.putExtra(EXTRA_PROVISIONED, isProfileOwner());
        startActivityInPrimary(response);
        // Queried by CtsVerifier in the primary side using startActivityForResult.
    } else if (action.equals(ACTION_QUERY_PROFILE_OWNER)) {
        Intent response = new Intent();
        response.putExtra(EXTRA_PROVISIONED, isProfileOwner());
        setResult(RESULT_OK, response);
        // Request to delete work profile.
    } else if (action.equals(ACTION_REMOVE_MANAGED_PROFILE)) {
        if (isProfileOwner()) {
            Log.d(TAG, "Clearing cross profile intents");
            mDevicePolicyManager.clearCrossProfileIntentFilters(mAdminReceiverComponent);
            mDevicePolicyManager.wipeData(0);
            showToast(R.string.provisioning_byod_profile_deleted);
        }
    } else if (action.equals(ACTION_INSTALL_APK)) {
        boolean allowNonMarket = intent.getBooleanExtra(EXTRA_ALLOW_NON_MARKET_APPS, false);
        boolean wasAllowed = getAllowNonMarket();

        // Update permission to install non-market apps
        setAllowNonMarket(allowNonMarket);
        mOriginalSettings.putBoolean(INSTALL_NON_MARKET_APPS, wasAllowed);

        // Request to install a non-market application- easiest way is to reinstall ourself
        final Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE)
                .setData(Uri.parse("package:" + getPackageName()))
                .putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true).putExtra(Intent.EXTRA_RETURN_RESULT, true);
        startActivityForResult(installIntent, REQUEST_INSTALL_PACKAGE);

        // Not yet ready to finish- wait until the result comes back
        return;
        // Queried by CtsVerifier in the primary side using startActivityForResult.
    } else if (action.equals(ACTION_CHECK_INTENT_FILTERS)) {
        final boolean intentFiltersSetForManagedIntents = new IntentFiltersTestHelper(this)
                .checkCrossProfileIntentFilters(IntentFiltersTestHelper.FLAG_INTENTS_FROM_MANAGED);
        setResult(intentFiltersSetForManagedIntents ? RESULT_OK : RESULT_FAILED, null);
    } else if (action.equals(ACTION_CAPTURE_AND_CHECK_IMAGE)) {
        // We need the camera permission to send the image capture intent.
        grantCameraPermissionToSelf();
        Intent captureImageIntent = getCaptureImageIntent();
        Pair<File, Uri> pair = getTempUri("image.jpg");
        mImageFile = pair.first;
        mImageUri = pair.second;
        captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
        if (captureImageIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(captureImageIntent, REQUEST_IMAGE_CAPTURE);
        } else {
            Log.e(TAG, "Capture image intent could not be resolved in managed profile.");
            showToast(R.string.provisioning_byod_capture_media_error);
            finish();
        }
        return;
    } else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)
            || action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT)) {
        // We need the camera permission to send the video capture intent.
        grantCameraPermissionToSelf();
        Intent captureVideoIntent = getCaptureVideoIntent();
        int videoCaptureRequestId;
        if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)) {
            mVideoUri = getTempUri("video.mp4").second;
            captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri);
            videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT;
        } else {
            videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT;
        }
        if (captureVideoIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(captureVideoIntent, videoCaptureRequestId);
        } else {
            Log.e(TAG, "Capture video intent could not be resolved in managed profile.");
            showToast(R.string.provisioning_byod_capture_media_error);
            finish();
        }
        return;
    } else if (action.equals(ACTION_CAPTURE_AND_CHECK_AUDIO)) {
        Intent captureAudioIntent = getCaptureAudioIntent();
        if (captureAudioIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(captureAudioIntent, REQUEST_AUDIO_CAPTURE);
        } else {
            Log.e(TAG, "Capture audio intent could not be resolved in managed profile.");
            showToast(R.string.provisioning_byod_capture_media_error);
            finish();
        }
        return;
    } else if (ACTION_KEYGUARD_DISABLED_FEATURES.equals(action)) {
        final int value = intent.getIntExtra(EXTRA_PARAMETER_1,
                DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE);
        mDevicePolicyManager.setKeyguardDisabledFeatures(mAdminReceiverComponent, value);
    } else if (ACTION_LOCKNOW.equals(action)) {
        mDevicePolicyManager.lockNow();
        setResult(RESULT_OK);
    } else if (action.equals(ACTION_TEST_NFC_BEAM)) {
        Intent testNfcBeamIntent = new Intent(this, NfcTestActivity.class);
        testNfcBeamIntent.putExtras(intent);
        startActivity(testNfcBeamIntent);
        finish();
        return;
    } else if (action.equals(ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG)) {
        sendIntentInsideChooser(new Intent(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_PERSONAL));
    } else if (action.equals(ACTION_TEST_APP_LINKING_DIALOG)) {
        mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(),
                UserManager.ALLOW_PARENT_PROFILE_APP_LINKING);
        Intent toSend = new Intent(Intent.ACTION_VIEW);
        toSend.setData(Uri.parse("http://com.android.cts.verifier"));
        sendIntentInsideChooser(toSend);
    } else if (action.equals(ACTION_SET_USER_RESTRICTION)) {
        final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1);
        if (restriction != null) {
            mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(),
                    restriction);
        }
    } else if (action.equals(ACTION_CLEAR_USER_RESTRICTION)) {
        final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1);
        if (restriction != null) {
            mDevicePolicyManager.clearUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(),
                    restriction);
        }
    } else if (action.equals(ACTION_BYOD_SET_LOCATION_AND_CHECK_UPDATES)) {
        handleLocationAction();
        return;
    } else if (action.equals(ACTION_NOTIFICATION)) {
        showNotification(Notification.VISIBILITY_PUBLIC);
    } else if (ACTION_NOTIFICATION_ON_LOCKSCREEN.equals(action)) {
        mDevicePolicyManager.lockNow();
        showNotification(Notification.VISIBILITY_PRIVATE);
    } else if (ACTION_CLEAR_NOTIFICATION.equals(action)) {
        mNotificationManager.cancel(NOTIFICATION_ID);
    } else if (ACTION_TEST_SELECT_WORK_CHALLENGE.equals(action)) {
        mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, Color.BLUE);
        mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent,
                getResources().getString(R.string.provisioning_byod_confirm_work_credentials_header));
        startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD));
    } else if (ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS.equals(action)) {
        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        Intent launchIntent = keyguardManager.createConfirmDeviceCredentialIntent(null, null);
        startActivity(launchIntent);
    } else if (ACTION_SET_ORGANIZATION_INFO.equals(action)) {
        if (intent.hasExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME)) {
            final String organizationName = intent
                    .getStringExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME);
            mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, organizationName);
        }
        final int organizationColor = intent.getIntExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_COLOR,
                mDevicePolicyManager.getOrganizationColor(mAdminReceiverComponent));
        mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, organizationColor);
    } else if (ACTION_TEST_PARENT_PROFILE_PASSWORD.equals(action)) {
        startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD));
    }
    // This activity has no UI and is only used to respond to CtsVerifier in the primary side.
    finish();
}

From source file:com.collecdoo.fragment.main.RegisterDriverPhotoFragment.java

private void openImageIntent(int uploadIndex) {
    //EasyImage.openChooserWithGallery(this,"Please choose",0);

    File imageFile = ImageHelper.createFile(context, "extend_picture.jpg");
    String cameraImageFullPath = imageFile.getAbsolutePath();
    cameraOutputFileUri = Uri.fromFile(imageFile);

    // Camera.// w  w  w. ja v  a 2s.co  m
    final List<Intent> cameraIntents = new ArrayList<Intent>();
    final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    final PackageManager packageManager = context.getPackageManager();
    final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
    for (ResolveInfo res : listCam) {
        final String packageName = res.activityInfo.packageName;
        final Intent intent = new Intent(captureIntent);
        intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
        intent.setPackage(packageName);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraOutputFileUri);
        cameraIntents.add(intent);
    }

    // Filesystem.
    final Intent galleryIntent = new Intent();
    galleryIntent.setType("image/*");
    galleryIntent.setAction(Intent.ACTION_PICK);

    // Chooser of filesystem options.
    final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source");

    // Add the camera options.
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {}));

    startActivityForResult(chooserIntent, uploadIndex);
}

From source file:com.samsung.multiwindow.MultiWindow.java

/**
 * Executes the request and returns PluginResult.
 * //from w  ww . j av  a 2s .c o m
 * @param action
 *            The action to be executed.
 * @param args
 *            JSONArray of arguments for the plugin.
 * @param callbackContext
 *            The callback id used when calling back into JavaScript.
 * @return A PluginResult object with a status and message.
 */
public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext)
        throws JSONException {

    int ret = -1;

    try {
        // window type argument index is same in all cases of
        // createmultiwindow
        windowType = args.getString(mainFsOptions.WINDOW_TYPE.ordinal());

        // Do not allow apis if metadata is missing
        if (!pluginMetadata) {
            callbackContext.error("METADATA_MISSING");
            Log.e("MultiWindow", "Metadata is missing");
            return false;
        }

        // Verify the multiwindow capability of the device
        ret = intializeMultiwindow();
        if (ret != INIT_SUCCESS) {

            switch (ret) {

            case SsdkUnsupportedException.VENDOR_NOT_SUPPORTED:
                callbackContext.error("VENDOR_NOT_SUPPORTED");
                break;
            case SsdkUnsupportedException.DEVICE_NOT_SUPPORTED:
                callbackContext.error("DEVICE_NOT_SUPPORTED");
                break;
            default:
                callbackContext.error("MUTLI_WINDOW_INITIALIZATION_FAILED");
                break;
            }

            return false;
        }

        if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
            Log.d(TAG, "Multiwindow initialization is successful" + ret);
        }

        // Check window support
        windowSupport = isMultiWindowSupported(windowType);
        if (windowType.equalsIgnoreCase("freestyle")) {

            if (!windowSupport) {
                callbackContext.error("FREE_STYLE_NOT_SUPPORTED");
            }

        } else if (windowType.equalsIgnoreCase("splitstyle")) {

            if (!windowSupport) {
                callbackContext.error("SPLIT_STYLE_NOT_SUPPORTED");
            }
        } else {

            callbackContext.error("INVALID_WINDOW_TYPE");
        }

        if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
            Log.d(TAG, "MultiWindow window type Supported:" + windowSupport);
        }

        // Get zone info in case of split style
        if (windowSupport && (action.equals("action_main") || action.equals("action_view"))) {

            if (windowType.equalsIgnoreCase("splitstyle")) {

                switch (args.optInt(mainSsOptions.ZONE_INFO.ordinal())) {
                case ZONE_A:
                    Log.d(TAG, "Zone A selected");
                    zoneInfo = SMultiWindowActivity.ZONE_A;
                    break;
                case ZONE_B:
                    Log.d(TAG, "Zone B selected");
                    zoneInfo = SMultiWindowActivity.ZONE_B;
                    break;
                case ZONE_FULL:
                    Log.d(TAG, "Zone Full selected");
                    zoneInfo = SMultiWindowActivity.ZONE_FULL;
                    break;
                default:
                    Log.d(TAG, "Zone is not selected");
                    callbackContext.error("INVALID_ZONEINFO");
                    return false;
                }
            }
        }
    } catch (Exception e) {

        callbackContext.error(e.getMessage());
    }

    if (action.equals("action_main")) {

        if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
            Log.d(TAG, "Action is action_main");
        }
        if (!windowSupport) {
            return false;
        }

        cordova.getThreadPool().execute(new Runnable() {

            public void run() {

                Intent intent = new Intent(Intent.ACTION_MAIN);
                int packageNameIndex = 0;
                int activityNameIndex = 0;
                float scaleInfo = 0;
                int zoneInfo = getZoneInfo();
                String windowType = getWindowType();

                if (windowType.equalsIgnoreCase("splitstyle")) {
                    packageNameIndex = mainSsOptions.PACKAGE_NAME.ordinal();
                    activityNameIndex = mainSsOptions.ACTIVITY_NAME.ordinal();
                } else {
                    packageNameIndex = mainFsOptions.PACKAGE_NAME.ordinal();
                    activityNameIndex = mainFsOptions.ACTIVITY_NAME.ordinal();
                }

                try {
                    intent.setComponent(new ComponentName(args.getString(packageNameIndex),
                            args.getString(activityNameIndex)));

                    if (windowType.equalsIgnoreCase("splitstyle")) {
                        SMultiWindowActivity.makeMultiWindowIntent(intent, zoneInfo);
                    } else {

                        scaleInfo = ((float) args.getDouble(mainFsOptions.SCALE_INFO.ordinal())) / 100;
                        if (scaleInfo < 0.6 || scaleInfo > 1.0) {
                            callbackContext.error("INVALID_SCALEINFO");
                            return;
                        }
                        SMultiWindowActivity.makeMultiWindowIntent(intent, scaleInfo);
                    }
                } catch (Exception e) { // May be JSONException

                    callbackContext.error(e.getMessage());
                }
                try {
                    cordova.getActivity().startActivity(intent);
                } catch (ActivityNotFoundException activityNotFound) {
                    callbackContext.error("ACTIVITY_NOT_FOUND");
                }

                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
            }
        });
        return true;

    } else if (action.equals("action_view")) {

        if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
            Log.d(TAG, "Action is action_view");
        }
        if (!windowSupport) {
            return false;
        }

        cordova.getThreadPool().execute(new Runnable() {

            public void run() {

                int dataUriIndex = 0;
                float scaleInfo = 0;
                Intent dataUrl = null;
                String windowType = getWindowType();
                int zoneInfo = getZoneInfo();

                if (windowType.equalsIgnoreCase("splitstyle")) {
                    dataUriIndex = viewSsOptions.DATA_URI.ordinal();

                } else {
                    dataUriIndex = viewFsOptions.DATA_URI.ordinal();
                }
                String dataUri = null;
                try {
                    dataUri = args.getString(dataUriIndex);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                if (dataUri == null || dataUri.equals("") || dataUri.equals("null")) {
                    callbackContext.error("INVALID_DATA_URI");
                    return;
                } else {
                    boolean isUriProper = false;
                    for (String schema : URI_SCHEMA_SUPPORTED) {
                        if (dataUri.startsWith(schema)) {
                            isUriProper = true;
                            break;
                        }
                    }
                    if (!isUriProper) {
                        callbackContext.error("INVALID_DATA_URI");
                        return;
                    }
                }
                try {
                    dataUrl = new Intent(Intent.ACTION_VIEW, Uri.parse(dataUri));

                    if (windowType.equalsIgnoreCase("splitstyle")) {
                        SMultiWindowActivity.makeMultiWindowIntent(dataUrl, zoneInfo);
                    } else {
                        scaleInfo = ((float) args.getDouble(viewFsOptions.SCALE_INFO.ordinal())) / 100;
                        if (scaleInfo < 0.6 || scaleInfo > 1.0) {
                            callbackContext.error("INVALID_SCALEINFO");
                            return;
                        }
                        SMultiWindowActivity.makeMultiWindowIntent(dataUrl, scaleInfo);
                    }
                } catch (Exception e) { // May be JSONException

                    callbackContext.error(e.getMessage());
                }

                try {

                    if (dataUrl != null) {
                        cordova.getActivity().startActivity(dataUrl);
                    }

                } catch (ActivityNotFoundException activityNotFound) {
                    callbackContext.error("ACTIVITY_NOT_FOUND");
                }
                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
            }
        });
        return true;

    } else if (action.equals("action_check")) {

        if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
            Log.d(TAG, "Action is action_check");
        }

        if (windowSupport) {

            callbackContext.success();
        }
        return true;

    } else if (action.equals("action_getapps")) {

        if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
            Log.d(TAG, "Action is action_getapps");
        }

        if (!windowSupport) {

            return false;
        }

        getMultiWindowApps(windowType, callbackContext);
        return true;

    }

    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, 0));
    return false;
}