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.cleanwiz.applock.ui.activity.SplashActivity.java

public void createDeskShortCut() {
    // ????/*from ww w . j av a  2  s .  c o  m*/
    SharedPreferenceUtil.editShortCut(true);
    Intent shortcutIntent = new Intent();
    shortcutIntent.setClass(this, SplashActivity.class);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    shortcutIntent.setAction("android.intent.action.MAIN");
    shortcutIntent.addCategory("android.intent.category.LAUNCHER");

    Intent resultIntent = new Intent();
    resultIntent.putExtra("duplicate", false);
    resultIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher));
    resultIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
    resultIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);

    resultIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
    sendBroadcast(resultIntent);
    resultIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    sendBroadcast(resultIntent);
}

From source file:net.hockeyapp.android.internal.CheckUpdateTask.java

private void startUpdateIntent(final JSONArray updateInfo, Boolean finish) {
    Class<?> activityClass = UpdateActivity.class;
    if (listener != null) {
        activityClass = listener.getUpdateActivityClass();
    }//from  w w w .  ja v a 2  s  . co m

    Intent intent = new Intent();
    intent.setClass(activity, activityClass);
    intent.putExtra("json", updateInfo.toString());
    intent.putExtra("url", getURLString("apk"));
    activity.startActivity(intent);

    if (finish) {
        activity.finish();
    }

    cleanUp();
}

From source file:com.kircherelectronics.gyroscopeexplorer.activity.GyroscopeActivity.java

/**
 * Event Handling for Individual menu item selected Identify single menu
 * item by it's id/*from www .  j  a  v  a 2 s  . c  om*/
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    // Reset everything
    case R.id.action_reset:
        orientationFusion.reset();
        return true;

    // Reset everything
    case R.id.action_config:
        Intent intent = new Intent();
        intent.setClass(this, ConfigActivity.class);
        startActivity(intent);
        return true;

    // Reset everything
    case R.id.action_help:
        showHelpDialog();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.aqtx.app.main.activity.MainActivity.java

private void onParseIntent() {
    Intent intent = getIntent();/*w w  w . j  a va  2 s.  c  o m*/
    if (intent.hasExtra(NimIntent.EXTRA_NOTIFY_CONTENT)) {
        IMMessage message = (IMMessage) getIntent().getSerializableExtra(NimIntent.EXTRA_NOTIFY_CONTENT);
        switch (message.getSessionType()) {
        case P2P:
            SessionHelper.startP2PSession(this, message.getSessionId());
            break;
        case Team:
            SessionHelper.startTeamSession(this, message.getSessionId());
            break;
        default:
            break;
        }
    } else if (intent.hasExtra(EXTRA_APP_QUIT)) {
        onLogout();
        return;
    } else if (intent.hasExtra(AVChatActivity.INTENT_ACTION_AVCHAT)) {
        if (AVChatProfile.getInstance().isAVChatting()) {
            Intent localIntent = new Intent();
            localIntent.setClass(this, AVChatActivity.class);
            startActivity(localIntent);
        }
    } else if (intent.hasExtra(Extras.EXTRA_JUMP_P2P)) {
        Intent data = intent.getParcelableExtra(Extras.EXTRA_DATA);
        String account = data.getStringExtra(Extras.EXTRA_ACCOUNT);
        if (!TextUtils.isEmpty(account)) {
            SessionHelper.startP2PSession(this, account);
        }
    }
}

From source file:com.starwood.anglerslong.LicenseActivity.java

/*****************************************************************************************************
 * Handles the onClick of the button/image
 *****************************************************************************************************
 * @param v Holds the clicked view//from w  w  w .  ja va2 s .co  m
 *****************************************************************************************************/
private void clickedItem(View v) {
    for (int i = 0; i < imageViewIdArray.length; i++) {
        if (v.getId() == imageViewIdArray[i]) {
            currentItemID = i;
            break;
        }
    }

    //*******************************************************************************************************
    // Only goes here if they clicked the DELETE button in the actionbar menu.
    //*******************************************************************************************************
    if (isDeletable) {
        AlertDialog.Builder builder = new AlertDialog.Builder(LicenseActivity.this);
        builder.setMessage("Are you sure you want to delete this item from the list?").setTitle("Delete")
                .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        try {
                            delete(currentItemID);
                            onBackPressed();
                            Toast.makeText(getApplicationContext(), "Your item has been deleted!",
                                    Toast.LENGTH_SHORT).show();
                        } catch (IOException | JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {

                    }
                });

        AlertDialog alert = builder.create();
        alert.show();
        isDeletable = false;
    }
    //*******************************************************************************************************
    // Go here if you just want to click the item, see info that's stored, and possibly add to it.
    //*******************************************************************************************************
    else {
        isEdit = true;
        Intent intent = new Intent();
        intent.setClass(getApplicationContext(), LicenseAddActivity.class);
        intent.putExtra("title", "License");
        intent.putExtra("isPopulated", isLicensePopulated);
        intent.putExtra("isArrayEmpty", isArrayEmpty);
        intent.putExtra("isEdit", isEdit);
        intent.putExtra("currentItemID", currentItemID);
        intent.putExtra("isLicense", true);
        startActivity(intent);
    }
}

From source file:gov.nasa.arc.geocam.geocam.CameraPreviewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Window and view properties
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.camera_preview);

    // Load bitmap from intent data and display in imageview
    mImageUri = getIntent().getData();/*ww  w.  jav  a2  s .c o m*/
    try {
        mImageData = new JSONObject(getIntent().getExtras().getString("data"));
    } catch (JSONException e1) {
        Log.d(GeoCamMobile.DEBUG_ID, "Error unserializing JSON data from intent");
        mImageData = new JSONObject();
    }

    try {
        final BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inSampleSize = 4;
        InputStream in = getContentResolver().openInputStream(mImageUri);
        Bitmap bitmap = BitmapFactory.decodeStream(in, null, opts);

        //Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mImageUri);
        ImageView imageView = (ImageView) findViewById(R.id.camera_preview_imageview);
        imageView.setAdjustViewBounds(true);
        imageView.setScaleType(ScaleType.CENTER_INSIDE);
        imageView.setImageBitmap(bitmap);
    } catch (FileNotFoundException e) {
        Log.d(GeoCamMobile.DEBUG_ID, "Error loading bitmap in CameraPreviewActivity");
    }

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    String defaultNotes = settings.getString(GeoCamMobile.SETTINGS_DEFAULT_NOTES_KEY, "");

    // Set default notes
    EditText notesText = (EditText) findViewById(R.id.camera_preview_edittext);
    notesText.setText(defaultNotes + " ");

    // Buttons
    mFireButton = (ImageButton) findViewById(R.id.camera_preview_fire_button);
    mFireButton.setImageDrawable(getResources().getDrawable(R.drawable.fire_icon_default));
    mFireButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_PICK);
            intent.setClass(CameraPreviewActivity.this, FireIconActivity.class);
            startActivityForResult(intent, PICK_ICON_REQUEST);
        }
    });

    final ImageButton deleteButton = (ImageButton) findViewById(R.id.camera_preview_delete_button);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            CameraPreviewActivity.this.showDialog(DIALOG_DELETE_PHOTO);
        }
    });

    final ImageButton saveButton = (ImageButton) findViewById(R.id.camera_preview_save_button);
    saveButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mImageNote = ((EditText) findViewById(R.id.camera_preview_edittext)).getText().toString();
            Log.d(GeoCamMobile.DEBUG_ID, "Setting image note to: " + mImageNote);
            saveWithAnnotation();
        }
    });

    mForeground = new ForegroundTracker(this);
}

From source file:net.dahanne.android.google.client.GoogleActivity.java

private void showGoogleOptions() {
    Connection<Google> findPrimaryConnection = connectionRepository.findPrimaryConnection(Google.class);
    Log.e(TAG, findPrimaryConnection.getDisplayName());

    String[] options = { "Disconnect", "Profile" };
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            options);//from   w  ww  .ja va2  s .co m
    ListView listView = (ListView) this.findViewById(R.id.google_activity_options_list);
    listView.setAdapter(arrayAdapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parentView, View childView, int position, long id) {
            Intent intent;
            switch (position) {
            case 0:
                disconnect();
                showConnectOption();
                break;
            case 1:
                intent = new Intent();
                intent.setClass(parentView.getContext(), GoogleProfileActivity.class);
                startActivity(intent);
                break;
            default:
                break;
            }
        }
    });
}

From source file:zjut.soft.finalwork.ui.SlidingActivity.java

@Override
public void onItemClick(int rank) {
    switch (rank) {
    case R.id.sliding_activity_user_manage:
        // /*from  ww  w .  j a  va 2 s. com*/
        showLeft();
        UserConfFragment userConfFrag = new UserConfFragment();
        this.getSupportFragmentManager().beginTransaction().replace(R.id.center_frame, userConfFrag).commit();
        break;
    case R.id.sliding_activity_pay_query:
        // 
        showLeft();
        PayQueryFragment payQueryFrag = new PayQueryFragment();
        this.getSupportFragmentManager().beginTransaction().replace(R.id.center_frame, payQueryFrag).commit();
        break;
    case R.id.sliding_activity_query_system:
        // 
        showLeft();
        QuerySystemFragment querySystemFrag = new QuerySystemFragment();
        this.getSupportFragmentManager().beginTransaction().replace(R.id.center_frame, querySystemFrag)
                .commit();
        break;
    case R.id.sliding_activity_about_us:
        //  
        showLeft();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                showRight();

            }
        }, 500);
        break;
    case R.id.sliding_activity_unregister_user:
        // 
        new AlertDialog.Builder(this).setTitle("").setMessage("?")
                .setPositiveButton("", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        sp.edit().putString("username", null).putString("password", null).putString("url", null)
                                .commit();
                        Intent i = new Intent();
                        i.setClass(SlidingActivity.this, LoginUI.class);
                        startActivity(i);
                        SlidingActivity.this.finish();
                        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                    }
                }).setNegativeButton("", null).create().show();
        break;
    case R.id.sliding_activity_pick_course_system:
    case R.id.sliding_activity_regist_system:
    case R.id.sliding_activity_student_rating:
        new AlertDialog.Builder(this).setTitle("").setMessage("...")
                .setNeutralButton("", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // do nothing
                    }
                }).create().show();
        break;
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java

private void showQR() {
    Intent qrIntent = new Intent(Intents.Encode.ACTION);
    qrIntent.setClass(getActivity(), EncodeActivity.class);
    qrIntent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
    qrIntent.putExtra(Intents.Encode.DATA,
            ThreadRequest.getInvitationUri(getActivity(), mExternalFeedUri).toString());
    startActivity(qrIntent);//from  ww  w  .  ja  v a2  s  .co  m
}

From source file:com.miz.mizuu.ShowDetails.java

private void searchCover() {
    Intent i = new Intent();
    i.putExtra("id", thisShow.getId());
    i.setClass(this, ShowCoverFanartBrowser.class);
    startActivity(i);//from w w w.j  a  v  a  2s.com
}