Example usage for android.content Intent setClass

List of usage examples for android.content Intent setClass

Introduction

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

Prototype

public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) 

Source Link

Document

Convenience for calling #setComponent(ComponentName) with the name returned by a Class object.

Usage

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openImage(final Context context, final Uri uri, final boolean is_possibly_sensitive) {
    if (context == null || uri == null)
        return;//from ww w .  j  a v  a 2  s.co m
    final Intent intent = new Intent(INTENT_ACTION_VIEW_IMAGE);
    intent.setDataAndType(uri, "image/*");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
        intent.setClass(context, ImageViewerGLActivity.class);
    } else {
        intent.setClass(context, ImageViewerActivity.class);
    }
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    if (context instanceof FragmentActivity && is_possibly_sensitive
            && !prefs.getBoolean(PREFERENCE_KEY_DISPLAY_SENSITIVE_CONTENTS, false)) {
        final FragmentActivity activity = (FragmentActivity) context;
        final FragmentManager fm = activity.getSupportFragmentManager();
        final DialogFragment fragment = new SensitiveContentWarningDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(INTENT_KEY_URI, uri);
        fragment.setArguments(args);
        fragment.show(fm, "sensitive_content_warning");
    } else {
        context.startActivity(intent);
    }
}

From source file:com.android.calendar.EventInfoFragment.java

private void doEdit() {
    Context c = getActivity();//from  w w  w .  j ava 2  s . c  o  m
    // This ensures that we aren't in the process of closing and have been
    // unattached already
    if (c != null) {
        Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId);
        Intent intent = new Intent(Intent.ACTION_EDIT, uri);
        intent.setClass(mActivity, EditEventActivity.class);
        intent.putExtra(EXTRA_EVENT_BEGIN_TIME, mStartMillis);
        intent.putExtra(EXTRA_EVENT_END_TIME, mEndMillis);
        intent.putExtra(EXTRA_EVENT_ALL_DAY, mAllDay);
        intent.putExtra(EditEventActivity.EXTRA_EVENT_COLOR, mCurrentColor);
        intent.putExtra(EditEventActivity.EXTRA_EVENT_REMINDERS, EventViewUtils
                .reminderItemsToReminders(mReminderViews, mReminderMinuteValues, mReminderMethodValues));
        intent.putExtra(EVENT_EDIT_ON_LAUNCH, true);
        startActivity(intent);
    }
}

From source file:com.andrew.apollo.MusicPlaybackService.java

public static void stopService(Context context) {
    LOG.info("stopService() <static>");
    Intent i = new Intent();
    i.setClass(context, MusicPlaybackService.class);
    context.stopService(i);/*from w  w  w  . j a v  a  2 s  .  co m*/
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

public void googlePurchase(final String jsonData) {

    DebugLog.d(TAG, "googlePurchase()");
    ((Activity) mContext).runOnUiThread(new Runnable() {

        @Override/*from   ww w  .  j  a va 2s  . co  m*/
        public void run() {
            // TODO Auto-generated method stub
            String result = null;
            Intent intent = new Intent();

            intent.setClass(mContext, GoogleBillingActivity.class);
            //intent.setClass(mContext, VzwSdkIntegrationApp.class);
            intent.putExtra("jsonData", jsonData);
            sIsBillingTriggered = true;//disable timeout single
            mWebviewActivity.startActivityForResult(intent, Constants.START_BILLINGACTIVITY_REQUEST_CODE);
        }

    });
}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * Set a new init script/*from ww w  . j  ava 2  s  . co  m*/
 */
private void setCustomScript() {
    Intent intent = new Intent();
    intent.setClass(this, CustomScriptActivity.class);
    startActivityForResult(intent, 0);
}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * Edit profile names/* www.jav a  2  s.com*/
 */
private void editProfileNames() {
    Intent intent = new Intent();
    intent.setClass(this, EditProfileNames.class);
    startActivityForResult(intent, EDIT_PROFILE_REQUEST);
}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * User Settings//from  w  w w .  j  a  v  a  2 s . co  m
 */
private void userSettings() {
    Intent intent = new Intent();
    intent.setClass(this, UserSettings.class);
    startActivityForResult(intent, USER_SETTINGS_REQUEST);
}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * Show iptable rules on a dialog//from   w  w w.  j  a  va  2s. c  o m
 */
private void showRules() {
    Intent intent = new Intent();
    intent.setClass(this, showRules.class);
    startActivityForResult(intent, 0);
}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * Dispay Help//from w  w w.ja  v a 2  s .c  om
 */

private void HelpDialog() {
    Intent intent = new Intent();
    intent.setClass(this, HelpDialog.class);
    startActivityForResult(intent, 0);
}

From source file:com.jtschohl.androidfirewall.MainActivity.java

public void selectProfile() {
    Intent intent = new Intent();
    intent.setClass(this, LoadProfile.class);
    File filepath = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/androidfirewall/");
    if (filepath.isDirectory()) {
        startActivityForResult(intent, LOAD_PROFILE_REQUEST);
    } else {/*from  www  . j a va  2  s .  co m*/
        Toast.makeText(this, R.string.no_rules_file, Toast.LENGTH_LONG).show();
    }
}