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.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

public void requestComplete() {
    if (ServerNode.thereAreNewRemoteCredentials()) {
        done();//w w  w .ja v a2 s  .co  m
        ServerNode.setThereAreNewRemoteCredentials(false);
        requestProgress.dismiss();
        Intent intent = new Intent();
        intent.setClass(LockActivity.this, KeyRevokeActivity.class);
        startActivityForResult(intent, 0);
    }
}

From source file:com.dgimenesmseii.droideye.CamListActivity.java

private void connectWithCAM() {
    Intent intent = new Intent();
    intent.setClass(CamListActivity.this, BridgeService.class);
    startService(intent);//from  w w w  .ja  va 2  s . c  o  m
    new Thread(new Runnable() {
        @Override
        public void run() {
            NativeCaller.PPPPInitial("ABC");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            BridgeService.setAddCameraInterface(CamListActivity.this);
        }
    }).start();
}

From source file:com.csipsimple.plugins.twvoip.CallHandler.java

@Override
public void onReceive(Context context, Intent intent) {
    if (ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) {

        PendingIntent pendingIntent = null;
        // Extract infos from intent received
        String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

        // Extract infos from settings
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, "");
        String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, "");
        String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, "");

        // We must handle that clean way cause when call just to
        // get the row in account list expect this to reply correctly
        if (!TextUtils.isEmpty(number) && !TextUtils.isEmpty(user) && !TextUtils.isEmpty(nbr)
                && !TextUtils.isEmpty(pwd)) {
            // Build pending intent
            Intent i = new Intent(ACTION_DO_TWVOIP_CALL);
            i.setClass(context, getClass());
            i.putExtra(Intent.EXTRA_PHONE_NUMBER, number);

            pendingIntent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
            // = PendingIntent.getActivity(context, 0, i, 0);
        }//from ww w  . ja va 2 s.c  om

        // Build icon
        Bitmap bmp = null;
        Drawable icon = context.getResources().getDrawable(R.drawable.icon);
        BitmapDrawable bd = ((BitmapDrawable) icon);
        bmp = bd.getBitmap();

        // Build the result for the row (label, icon, pending intent, and
        // excluded phone number)
        Bundle results = getResultExtras(true);
        if (pendingIntent != null) {
            results.putParcelable(Intent.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent);
        }
        results.putString(Intent.EXTRA_TITLE, "12voip WebCallback");
        if (bmp != null) {
            results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, bmp);
        }

        // DO *NOT* exclude from next tel: intent cause we use a http method
        // results.putString(Intent.EXTRA_PHONE_NUMBER, number);

    } else if (ACTION_DO_TWVOIP_CALL.equals(intent.getAction())) {

        // Extract infos from intent received
        String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

        // Extract infos from settings
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, "");
        String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, "");
        String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, "");

        // params
        List<NameValuePair> params = new LinkedList<NameValuePair>();
        params.add(new BasicNameValuePair("username", user));
        params.add(new BasicNameValuePair("password", pwd));
        params.add(new BasicNameValuePair("from", nbr));
        params.add(new BasicNameValuePair("to", number));
        String paramString = URLEncodedUtils.format(params, "utf-8");

        String requestURL = "https://www.12voip.com//myaccount/makecall.php?" + paramString;

        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(requestURL);

        // Create a response handler
        HttpResponse httpResponse;
        try {
            httpResponse = httpClient.execute(httpGet);
            Log.d(THIS_FILE, "response code is " + httpResponse.getStatusLine().getStatusCode());
            if (httpResponse.getStatusLine().getStatusCode() == 200) {
                InputStreamReader isr = new InputStreamReader(httpResponse.getEntity().getContent());
                BufferedReader br = new BufferedReader(isr);

                String line;
                String fullReply = "";
                boolean foundSuccess = false;
                while ((line = br.readLine()) != null) {
                    if (!TextUtils.isEmpty(line) && line.toLowerCase().contains("success")) {
                        showToaster(context, "Success... wait a while you'll called back");
                        foundSuccess = true;
                        break;
                    }
                    if (!TextUtils.isEmpty(line)) {
                        fullReply = fullReply.concat(line);
                    }
                }
                if (!foundSuccess) {
                    showToaster(context, "Error : server error : " + fullReply);
                }
            } else {
                showToaster(context, "Error : invalid request " + httpResponse.getStatusLine().getStatusCode());
            }
        } catch (ClientProtocolException e) {
            showToaster(context, "Error : " + e.getLocalizedMessage());
        } catch (IOException e) {
            showToaster(context, "Error : " + e.getLocalizedMessage());
        }

    }
}

From source file:ca.ualberta.cs.shoven_habittracker.MainActivity.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    Intent intent = new Intent();
    intent.setClass(this, HabitHomepageActivity.class);
    Bundle bundle = new Bundle();
    bundle.putInt("position", position);
    bundle.putString("activity", "MainActivity");
    intent.putExtras(bundle);/* w  ww .  j a  va 2 s  .c om*/
    startActivity(intent);
}

From source file:com.apptentive.android.sdk.ApptentiveInternal.java

public static PendingIntent prepareMessageCenterPendingIntent(Context context) {
    Intent intent;
    if (Apptentive.canShowMessageCenter()) {
        intent = new Intent();
        intent.setClass(context, ApptentiveViewActivity.class);
        intent.putExtra(Constants.FragmentConfigKeys.TYPE, Constants.FragmentTypes.ENGAGE_INTERNAL_EVENT);
        intent.putExtra(Constants.FragmentConfigKeys.EXTRA,
                MessageCenterInteraction.DEFAULT_INTERNAL_EVENT_NAME);
    } else {/*from  www . j  a  va  2  s  .c o m*/
        intent = MessageCenterInteraction.generateMessageCenterErrorIntent(context);
    }
    return (intent != null)
            ? PendingIntent.getActivity(context, 0, intent,
                    PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT)
            : null;
}

From source file:com.gsma.rcs.ri.extension.MultiMediaSessionIntentService.java

private void addSessionInvitationNotification(Intent intent, ContactId contact) {
    /* Create pending intent */
    Intent invitation = new Intent(intent);
    String title;//w  w  w  .  ja v  a 2  s . com
    if (mMultimediaMessagingSession) {
        invitation.setClass(this, MessagingSessionView.class);
        title = getString(R.string.title_recv_messaging_session);
    } else {
        invitation.setClass(this, StreamingSessionView.class);
        title = getString(R.string.title_recv_streaming_session);
    }
    invitation.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    /*
     * If the PendingIntent has the same operation, action, data, categories, components, and
     * flags it will be replaced. Invitation should be notified individually so we use a random
     * generator to provide a unique request code and reuse it for the notification.
     */
    int uniqueId = Utils.getUniqueIdForPendingIntent();
    PendingIntent contentIntent = PendingIntent.getActivity(this, uniqueId, invitation,
            PendingIntent.FLAG_ONE_SHOT);

    String displayName = RcsContactUtil.getInstance(this).getDisplayName(contact);

    /* Create notification */
    NotificationCompat.Builder notif = new NotificationCompat.Builder(this);
    notif.setContentIntent(contentIntent);
    notif.setSmallIcon(R.drawable.ri_notif_mm_session_icon);
    notif.setWhen(System.currentTimeMillis());
    notif.setAutoCancel(true);
    notif.setOnlyAlertOnce(true);
    notif.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
    notif.setDefaults(Notification.DEFAULT_VIBRATE);
    notif.setContentTitle(title);
    notif.setContentText(getString(R.string.label_from_args, displayName));

    /* Send notification */
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.notify(uniqueId, notif.build());
}

From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        Intent intent = new Intent();
        intent.setClass(LockActivity.this, AdvancedPreferenceActivity.class);
        startActivityForResult(intent, 0);
        return true;
    } else if (id == R.id.action_reset) {
        PreferenceManager.getDefaultSharedPreferences(this).edit().clear().apply(); //reset
        PreferenceManager.setDefaultValues(this, R.xml.advanced, true);
        return true;
    } else if (id == R.id.action_quit) {
        Intent i = new Intent(this, RviService.class);
        stopService(i);/*from   w  w  w  .  j  ava 2  s .  c  o  m*/
        finish();
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.ToAddJustificationDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle b = getArguments();//from   w ww  . j ava2s .c o  m
    String motion_LID = b.getString(Motion.M_MOTION_LID);
    type = b.getString(Motion.M_MOTION_CHOICE);
    jLID = b.getString(Motion.J_JUSTIFICATION_LID);
    scnt = b.getString(Motion.M_MOTION_ID);

    if (motion_LID != null) {
        crt_motion = D_Motion.getMotiByLID(motion_LID, false, false);
        if (crt_motion != null) {
            if (jLID != null) {
                crt_justification = new JustificationSupportEntry(jLID, Util.ival(scnt, 0));
                init(crt_motion, crt_justification, type);
            } else {
                init(crt_motion, type);
            }
        }
    }
    View view = inflater.inflate(R.layout.dialog_to_add_justification, container);
    final Button butYes = (Button) view.findViewById(R.id.dialog_add_new_justification);
    final Button butNo = (Button) view.findViewById(R.id.do_not_add_new_justification);

    getDialog().setTitle("Justification");

    // add a new justification
    butYes.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            D_Constituent myself = Identity.getCrtConstituent(oLID);
            if (myself == null) {
                Toast.makeText(getActivity(), "Fill your Profile!", Toast.LENGTH_LONG);
                return;
            }
            Intent i = new Intent();
            i.setClass(getActivity(), AddJustification.class);
            Bundle b = new Bundle();
            b.putString(Motion.M_MOTION_CHOICE, ToAddJustificationDialog.this.type);
            b.putString(Motion.M_MOTION_LID, ToAddJustificationDialog.this.crt_motion.getLIDstr());
            String jLID = "";
            if (ToAddJustificationDialog.this.crt_justification != null)
                jLID = ToAddJustificationDialog.this.crt_justification.getJustification_LIDstr();
            b.putString(Motion.J_JUSTIFICATION_LID, jLID);
            i.putExtras(b);
            startActivity(i);
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.detach(ToAddJustificationDialog.this);
            ft.commit();
            Toast.makeText(getActivity(), "Add a new justification", Toast.LENGTH_SHORT).show();
        }
    });

    // if not add a new justification
    butNo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            D_Constituent myself = Identity.getCrtConstituent(oLID);
            if (myself == null) {
                Toast.makeText(getActivity(), "Fill your Profile!", Toast.LENGTH_LONG);
                return;
            }
            D_Justification j = null;
            if (ToAddJustificationDialog.this.crt_justification != null)
                j = D_Justification.getJustByLID(
                        ToAddJustificationDialog.this.crt_justification.getJustification_LIDstr(), true, false);
            D_Vote vote = D_Vote.createVote(crt_motion, j, type);
            if (DEBUG)
                Log.d("VOTE", "Bad vote=" + vote);

            // D_Vote vote = new D_Vote();
            // vote.setMotionAndOrganizationAll(crt_motion);
            // if (ToAddJustificationDialog.this.crt_justification != null)
            // {
            // D_Justification j =
            // D_Justification.getJustByLID(ToAddJustificationDialog.this.crt_justification.getJustification_LIDstr(),
            // true, false);
            // if (j != null) vote.setJustificationAll(j);
            // }
            // vote.setConstituentAll(Identity.getCrtConstituent(crt_motion.getOrganizationLID()));
            // String choice = type;
            // Log.d("VOTE", "Sign type="+type);
            // vote.setChoice(choice);
            // Log.d("VOTE", "Sign oLID="+crt_motion.getOrganizationLID());
            //
            // Log.d("VOTE", "Sign oLID="+vote);
            // vote.sign();
            // try {
            // vote.storeVerified();
            // } catch (P2PDDSQLException e) {
            // e.printStackTrace();
            // }

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.detach(ToAddJustificationDialog.this);
            ft.commit();

            Intent intent = getActivity().getIntent();
            getActivity().finish();
            startActivity(intent);
        }
    });

    return view;
}

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

private void attemptLogin() {
    Intent intent = new Intent();
    intent.setClass(getApplicationContext(), FileSourceBrowser.class);
    intent.putExtra(USER, mUser);/*from  w  w w.  java 2 s .c o m*/
    intent.putExtra(PASSWORD, mPass);
    intent.putExtra(DOMAIN, mDomain);
    intent.putExtra(SERVER, mServer);
    intent.putExtra(TYPE, isMovie ? MOVIE : TV_SHOW);
    intent.putExtra(FILESOURCE, FileSource.SMB);
    startActivity(intent);
    finish();
}

From source file:An.stop.AnstopActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent i = new Intent();

    switch (item.getItemId()) {
    case R.id.menu_settings:
        i.setClass(this, SettingsActivity.class);
        startActivityForResult(i, SETTINGS_REQUEST_CODE);
        // on result, will call readSettings(false).
        return true;

    case R.id.menu_item_stop:
        viewPager.setCurrentItem(0);/*from   w  ww .  j  a  v  a  2s  . c  o  m*/
        return true;

    case R.id.menu_item_countdown:
        viewPager.setCurrentItem(1);
        return true;

    case R.id.menu_about:
        showDialog(ABOUT_DIALOG);
        return true;

    case R.id.menu_save:
        showDialog(SAVE_DIALOG);
        return true;

    case R.id.menu_send:
        //TODO
        Util.startSendMailIntent(this, getResources().getString(R.string.app_name) + ": ", ""); //currentModeAsString(), createBodyFromCurrent());
        return true;

    case R.id.menu_load:
        i.setClass(this, LoadActivity.class);
        startActivity(i);
        return true;

    }
    return false;
}