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.example.mp_master.BasicAuthLogin.java

/**
 * login//from www.  j a v  a  2s.c  om
 */
private void toRegisterActivity() {
    Intent intent = new Intent();
    intent.setClass(BasicAuthLogin.this, RegisterActivity.class);
    startActivity(intent);
    overridePendingTransition(R.anim.push_left_out, R.anim.push_right_in);
}

From source file:com.hagreve.android.fragments.HaGreveListFragment.java

private void showDetails(int position) {
    if (position < 0)
        return;/*  ww  w. j a va 2s . c om*/

    if (getListAdapter().getCount() > 0 && position >= 0) {
        Intent intent = new Intent();
        intent.setClass(getActivity(), HaGreveDetailActivity.class);

        Strike item = (Strike) getListAdapter().getItem(position);

        intent.putExtra("strike", item);

        startActivity(intent);
    }
}

From source file:com.example.mp_master.BasicAuthLogin.java

/**
 * main/*w  w w. j a  v  a2 s  . c  o m*/
 */
private void toFragmentChangeActivity() {
    MPClientApp.USERNAME = mUsername;
    MPClientApp.USERPWD = mPassword;
    SPSetting.save(MPClientApp.USERNAME_KEY, mUsername, MPClientApp.getGlobalContext());
    SPSetting.save(MPClientApp.USERPWD_KEY, mPassword, MPClientApp.getGlobalContext());
    Intent intent = new Intent();
    intent.setClass(BasicAuthLogin.this, FragmentChangeActivity.class);
    startActivity(intent);
    finish();
    overridePendingTransition(R.anim.push_left_out, R.anim.push_right_in);
}

From source file:com.loadsensing.app.LlistaXarxesActivity.java

protected void onListItemClick(ListView l, View v, int position, long id) {
    // obtenim el valor de la xarxa amb el camp ocult text6 del layout i obrim la nova pantalla de llistat de sensors
    TextView c = (TextView) v.findViewById(R.id.text6);
    String idxarxaselected = c.getText().toString();

    Intent intent = new Intent();
    intent.setClass(this.getApplicationContext(), SensorsActivity.class);
    intent.putExtra("idxarxaselected", idxarxaselected);
    startActivity(intent);//from  w  ww  .jav a 2  s.co  m

}

From source file:org.kepennar.android.client.social.twitter.TwitterWebOAuthActivity.java

private void displayTwitterOptions() {
    Intent intent = new Intent();
    intent.setClass(this, TwitterActivity.class);
    startActivity(intent);/*from   ww  w. ja v  a  2  s. c o m*/
    finish();
}

From source file:me.xingrz.finder.EntriesActivity.java

public void startFinder(Intent intent, Class<? extends EntriesActivity> activity) {
    intent.setClass(this, activity);
    intent.putExtra(EXTRA_ALLOW_BACK, true);
    startActivity(intent);/*  w  w  w .  jav  a  2s  .  c  o  m*/
    overridePendingTransition(R.anim.slide_in, 0);
}

From source file:com.gsma.rcs.ri.sharing.image.ImageSharingIntentService.java

/**
 * Add image share notification//from w  w  w  . j  ava2  s.  co m
 * 
 * @param invitation Intent invitation
 * @param ishDao the image sharing data object
 */
private void addImageSharingInvitationNotification(Intent invitation, ImageSharingDAO ishDao) {
    ContactId contact = ishDao.getContact();
    if (contact == null) {
        if (LogUtils.isActive) {
            Log.e(LOGTAG, "addImageSharingInvitationNotification failed: cannot parse contact");
        }
        return;
    }
    /* Create pending intent */
    Intent intent = new Intent(invitation);
    intent.setClass(this, ReceiveImageSharing.class);
    intent.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, intent,
            PendingIntent.FLAG_ONE_SHOT);

    String displayName = RcsContactUtil.getInstance(this).getDisplayName(contact);
    String title = getString(R.string.title_recv_image_sharing);

    /* Create notification */
    NotificationCompat.Builder notif = new NotificationCompat.Builder(this);
    notif.setContentIntent(contentIntent);
    notif.setSmallIcon(R.drawable.ri_notif_csh_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.gsma.rcs.ri.sharing.video.VideoSharingIntentService.java

/**
 * Add video share notification//from   ww  w . j ava2  s .co m
 * 
 * @param invitation Intent invitation
 * @param vshDao the video sharing data object
 */
public void addVideoSharingInvitationNotification(Intent invitation, VideoSharingDAO vshDao) {
    if (vshDao.getContact() == null) {
        if (LogUtils.isActive) {
            Log.e(LOGTAG, "VideoSharingInvitationReceiver failed: cannot parse contact");
        }
        return;
    }
    /* Create pending intent */
    Intent intent = new Intent(invitation);
    intent.setClass(this, IncomingVideoSharing.class);
    intent.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, intent,
            PendingIntent.FLAG_ONE_SHOT);

    String displayName = RcsContactUtil.getInstance(this).getDisplayName(vshDao.getContact());
    String notifTitle = getString(R.string.title_recv_video_sharing);

    /* Create notification */
    NotificationCompat.Builder notif = new NotificationCompat.Builder(this);
    notif.setContentIntent(contentIntent);
    notif.setSmallIcon(R.drawable.ri_notif_csh_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(notifTitle);
    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.gotraveling.insthub.BeeFramework.service.PushMessageReceiver.java

@Override
public void onNotificationClicked(Context context, String title, String description,
        String customContentString) {
    String notifyString = " title=" + title + " description=" + description + " customContent="
            + customContentString;//from   w w  w .  ja va 2  s.co m
    //System.out.println("notifyString:"+notifyString);

    Intent responseIntent = null;
    responseIntent = new Intent(EcmobileMainActivity.ACTION_PUSHCLICK);
    responseIntent.setClass(context, EcmobileMainActivity.class);
    responseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (customContentString != null) {
        responseIntent.putExtra(EcmobileMainActivity.CUSTOM_CONTENT, customContentString);
    }
    context.startActivity(responseIntent);
}

From source file:com.example.android.lnotifications.HeadsUpNotificationFragment.java

/**
 * Creates a new notification depending on the argument.
 *
 * @param makeHeadsUpNotification A boolean value to indicating whether a notification will be
 *                                created as a heads-up notification or not.
 *                                <ul>
 *                                <li>true : Creates a heads-up notification.</li>
 *                                <li>false : Creates a non-heads-up notification.</li>
 *                                </ul>
 *
 * @return A Notification instance./*from  w  w  w  . ja  v  a2s  .c o  m*/
 */
private Notification createNotification(boolean makeHeadsUpNotification) {
    Notification.Builder notificationBuilder = new Notification.Builder(getActivity())
            .setSmallIcon(R.drawable.ic_launcher_notification).setPriority(Notification.PRIORITY_DEFAULT)
            .setCategory(Notification.CATEGORY_MESSAGE).setContentTitle("Sample Notification")
            .setContentText("This is a normal notification.");
    if (makeHeadsUpNotification) {
        Intent push = new Intent();
        push.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        push.setClass(getActivity(), LNotificationActivity.class);

        PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(getActivity(), 0, push,
                PendingIntent.FLAG_CANCEL_CURRENT);
        notificationBuilder.setContentText("Heads-Up Notification on Android L or above.")
                .setFullScreenIntent(fullScreenPendingIntent, true);
    }
    return notificationBuilder.build();
}