Example usage for android.content Intent setClassName

List of usage examples for android.content Intent setClassName

Introduction

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

Prototype

public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) 

Source Link

Document

Convenience for calling #setComponent with an explicit application package name and class name.

Usage

From source file:com.ryg.dynamicload.DLBasePluginFragmentActivity.java

protected void startActivityByProxy(String className) {
    if (mFrom == DLConstants.FROM_INTERNAL) {
        Intent intent = new Intent();
        intent.setClassName(this, className);
        mProxyActivity.startActivity(intent);
    } else {/* w w w.  j  av  a  2  s  .c om*/
        Intent intent = new Intent(DLUtils.getProxyViewAction(className, getClassLoader()));
        intent.putExtra(DLConstants.EXTRA_DEX_PATH, mDexPath);
        intent.putExtra(DLConstants.EXTRA_CLASS, className);
        mProxyActivity.startActivity(intent);
    }
}

From source file:com.ryg.dynamicload.DLBasePluginFragmentActivity.java

public void startActivityForResultByProxy(String className, int requestCode) {
    if (mFrom == DLConstants.FROM_INTERNAL) {
        Intent intent = new Intent();
        intent.setClassName(this, className);
        mProxyActivity.startActivityForResult(intent, requestCode);
    } else {/*  www  .  j  av  a 2s . c  o m*/
        Intent intent = new Intent(DLUtils.getProxyViewAction(className, getClassLoader()));
        intent.putExtra(DLConstants.EXTRA_DEX_PATH, mDexPath);
        intent.putExtra(DLConstants.EXTRA_CLASS, className);
        mProxyActivity.startActivityForResult(intent, requestCode);
    }
}

From source file:com.fastbootmobile.encore.app.fragments.WelcomeFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Step specifics
    if (mStep == 2) {
        View root = getView();/*from   w  w  w. j  a  va  2 s .  co m*/
        if (root != null) {
            root.findViewById(R.id.btnSkip).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
                    dialog.setTitle(R.string.welcome_skip_dialog_title);
                    dialog.setMessage(R.string.welcome_skip_dialog_body);
                    dialog.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finishWizard();
                        }
                    });
                    dialog.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    dialog.show();
                }
            });

            root.findViewById(R.id.btnBrowse).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ProviderDownloadDialog.newInstance(false).show(getFragmentManager(), "Download");
                }
            });
        }
    } else if (mStep == 3) {
        // Step 3: Configure plugins
        ListView lv = (ListView) view.findViewById(R.id.lvProviders);
        List<ProviderConnection> allProvs = PluginsLookup.getDefault().getAvailableProviders();
        final List<ProviderConnection> provs = new ArrayList<>();

        for (ProviderConnection prov : allProvs) {
            if (prov.getConfigurationActivity() != null
                    && !TextUtils.isEmpty(prov.getConfigurationActivity())) {
                provs.add(prov);
            }
        }

        mStep3Adapter = new ProvidersAdapter(provs);
        mStep3Adapter.setWhite(true);
        mStep3Adapter.setWashOutConfigure(true);
        lv.setAdapter(mStep3Adapter);

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ProviderConnection connection = provs.get(position);
                Intent intent = new Intent();
                intent.setPackage(connection.getPackage());
                intent.setClassName(connection.getPackage(), connection.getConfigurationActivity());
                mConfiguringProvider = connection;
                try {
                    startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(getActivity(), R.string.toast_retry_plugin_not_ready, Toast.LENGTH_SHORT)
                            .show();
                }
            }
        });
    }
}

From source file:com.artech.android.gcm.GcmIntentService.java

@SuppressLint("InlinedApi")
public void createNotification(String payload, String action, String notificationParameters) {
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    String appName = getString(R.string.app_name);

    SharedPreferences settings = MyApplication.getInstance().getAppSharedPreferences();
    int notificatonID = settings.getInt("notificationID", 0); // allow multiple notifications //$NON-NLS-1$

    Intent intent = new Intent("android.intent.action.MAIN"); //$NON-NLS-1$
    intent.setClassName(this, getPackageName() + ".Main"); //$NON-NLS-1$
    intent.addCategory("android.intent.category.LAUNCHER"); //$NON-NLS-1$

    if (Services.Strings.hasValue(action)) {
        // call main as root of the stack with the action as intent parameter. Use clear_task like GoHome
        if (CompatibilityHelper.isApiLevel(Build.VERSION_CODES.HONEYCOMB))
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        else/*from   w ww .  ja v  a 2  s.co m*/
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

        intent.putExtra(IntentParameters.NotificationAction, action);
        intent.putExtra(IntentParameters.NotificationParameters, notificationParameters);
        intent.setAction(String.valueOf(Math.random()));
    } else {
        // call main like main application shortcut
        intent.setFlags(0);
        intent.setAction("android.intent.action.MAIN");
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Notification notification = NotificationHelper.newBuilder(this).setWhen(System.currentTimeMillis())
            .setContentTitle(appName).setContentText(payload).setContentIntent(pendingIntent)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(payload))
            .setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true).build();

    notificationManager.notify(notificatonID, notification);

    SharedPreferences.Editor editor = settings.edit();
    editor.putInt("notificationID", ++notificatonID % 32); //$NON-NLS-1$
    editor.commit();
}

From source file:org.mariotaku.twidere.fragment.ExtensionsListFragment.java

@Override
public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position,
        final long id) {
    mSelectedExtension = mAdapter.getItem(position);
    if (mSelectedExtension == null)
        return false;
    mPopupMenu = PopupMenu.getInstance(getActivity(), view);
    mPopupMenu.inflate(R.menu.action_extension);
    final Menu menu = mPopupMenu.getMenu();
    final MenuItem settings = menu.findItem(MENU_SETTINGS);
    final Intent intent = mSelectedExtension.pname != null && mSelectedExtension.settings != null
            ? new Intent(INTENT_ACTION_EXTENSION_SETTINGS)
            : null;/* w  ww .j a v  a 2 s .  c o m*/
    if (intent != null) {
        intent.setClassName(mSelectedExtension.pname, mSelectedExtension.settings);
    }
    settings.setVisible(intent != null && mPackageManager.queryIntentActivities(intent, 0).size() == 1);
    mPopupMenu.setOnMenuItemClickListener(this);
    mPopupMenu.show();
    return true;
}

From source file:com.javielinux.utils.Utils.java

public static void sendLastCrash(Activity cnt) {
    try {//from   w w  w .ja v  a2 s .  c  o m
        Intent gmail = new Intent(Intent.ACTION_VIEW);
        gmail.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
        gmail.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) });
        gmail.setData(Uri.parse(cnt.getString(R.string.email_send_errors)));
        gmail.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash");
        gmail.setType("plain/text");
        gmail.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt));
        cnt.startActivity(gmail);
    } catch (ActivityNotFoundException e) {
        Intent msg = new Intent(Intent.ACTION_SEND);
        msg.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) });
        msg.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash");
        msg.setType("plain/text");
        msg.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt));
        cnt.startActivity(msg);
    }
}

From source file:com.flipzu.flipzu.Profile.java

private Void logoutProfile() {
    /* track "Logout" */
    tracker.trackEvent("Profile", "Click", "Logout", 0);

    /* stop Profile service */

    SharedPreferences.Editor editor = settings.edit();
    editor.putString("username", null);
    editor.putString("token", null);
    editor.commit();//from  ww  w. j  a v  a 2 s .c o m
    Intent loginIntent = new Intent();
    loginIntent.setClassName("com.flipzu.flipzu", "com.flipzu.flipzu.Flipzu");
    startActivity(loginIntent);
    Profile.this.finish();
    return null;
}

From source file:org.zeroxlab.benchmark.Case.java

protected Intent generateIntent() {
    /* if run out of the repeat times, go back directly */
    if (mRepeatNow >= mRepeatMax) {
        return null;
    }// w w w . jav  a 2  s. co  m

    Intent intent = new Intent();
    intent.setClassName(PACKAGE, TESTER);
    Case.putRound(intent, mCaseRound);
    Case.putSwWindow(intent, mSwWin);
    Case.putSwLayer(intent, mSwLayer);
    Case.putSource(intent, TAG);
    Case.putIndex(intent, mRepeatNow);

    mRepeatNow = mRepeatNow + 1;

    return intent;
}

From source file:ch.ethz.coss.nervousnet.sample.SampleAppActivity.java

protected void doBindService() {
    Log.d("SensorDisplayActivity", "doBindService successfull");
    Intent it = new Intent();
    it.setClassName("ch.ethz.coss.nervousnet.hub", "ch.ethz.coss.nervousnet.hub.NervousnetHubApiService");
    bindFlag = getApplicationContext().bindService(it, mServiceConnection, 0);

}

From source file:org.hansel.myAlert.LocationManagement.java

private void enableGPS() {
    Log.v("Intentamos Activar el GPS(no funciona en todas las versiones) ");
    String provider = Settings.Secure.getString(getApplication().getContentResolver(),
            Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

    if (!provider.contains("gps")) {
        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"));
        getApplication().sendBroadcast(poke);
    }/*from   www.j  a  v  a 2 s  .c  o  m*/
}