List of usage examples for android.content Intent setClass
public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls)
From source file:com.example.android.samplesync.syncadapter.SyncAdapter.java
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {/*w w w . ja v a 2 s.c o m*/ Log.e(TAG, "SyncAdapter==============onPerformSync"); try { // see if we already have a sync-state attached to this account. By // handing // This value to the server, we can just get the contacts that have // been updated on the server-side since our last sync-up long lastSyncMarker = getServerSyncMarker(account); // By default, contacts from a 3rd party provider are hidden in the // contacts // list. So let's set the flag that causes them to be visible, so // that users // can actually see these contacts. if (lastSyncMarker == 0) { ContactManager.setAccountContactsVisibility(getContext(), account, true); } List<RawContact> dirtyContacts; List<RawContact> updatedContacts; // Use the account manager to request the AuthToken we'll need // to talk to our sample server. If we don't have an AuthToken // yet, this could involve a round-trip to the server to request // and AuthToken. final String authtoken = mAccountManager.blockingGetAuthToken(account, Constants.AUTHTOKEN_TYPE, NOTIFY_AUTH_FAILURE); // Make sure that the sample group exists final long groupId = ContactManager.ensureSampleGroupExists(mContext, account); // Find the local 'dirty' contacts that we need to tell the server // about... // Find the local users that need to be sync'd to the server... dirtyContacts = ContactManager.getDirtyContacts(mContext, account); // Send the dirty contacts to the server, and retrieve the // server-side changes updatedContacts = NetworkUtilities.syncContacts(account, authtoken, lastSyncMarker, dirtyContacts); // Update the local contacts database with the changes. // updateContacts() // returns a syncState value that indicates the high-water-mark for // the changes we received. Log.d(TAG, "Calling contactManager's sync contacts"); long newSyncState = ContactManager.updateContacts(mContext, account.name, updatedContacts, groupId, lastSyncMarker); // This is a demo of how you can update IM-style status messages // for contacts on the client. This probably won't apply to // 2-way contact sync providers - it's more likely that one-way // sync providers (IM clients, social networking apps, etc) would // use this feature. ContactManager.updateStatusMessages(mContext, updatedContacts); // Save off the new sync marker. On our next sync, we only want to // receive // contacts that have changed since this sync... setServerSyncMarker(account, newSyncState); if (dirtyContacts.size() > 0) { ContactManager.clearSyncFlags(mContext, dirtyContacts); } } catch (final AuthenticatorException e) { Log.e(TAG, "AuthenticatorException", e); syncResult.stats.numParseExceptions++; } catch (final OperationCanceledException e) { Log.e(TAG, "OperationCanceledExcetpion", e); } catch (final IOException e) { Log.e(TAG, "IOException", e); syncResult.stats.numIoExceptions++; } catch (final AuthenticationException e) { Log.e(TAG, "AuthenticationException", e); syncResult.stats.numAuthExceptions++; } catch (final ParseException e) { Log.e(TAG, "ParseException", e); syncResult.stats.numParseExceptions++; } catch (final JSONException e) { Log.e(TAG, "JSONException", e); syncResult.stats.numParseExceptions++; } // Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClass(mContext.getApplicationContext(), AuthenticatorActivity.class); mContext.startActivity(intent); }
From source file:com.cellbots.remoteEyes.RemoteEyesActivity.java
/** Called when the activity is first created. */ @Override/*from w ww . j a v a 2 s . co m*/ public void onCreate(Bundle savedInstanceState) { Log.e("remote eyes", "started"); super.onCreate(savedInstanceState); mTorchMode = false; out = new ByteArrayOutputStream(); if ((getIntent() != null) && (getIntent().getData() != null)) { putUrl = getIntent().getData().toString(); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); Bundle extras = getIntent().getExtras(); if ((extras != null) && (extras.getBoolean("TORCH", false))) { mTorchMode = true; } } else { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); putUrl = prefs.getString("REMOTE_EYES_PUT_URL", ""); Log.e("prefs", putUrl); if (putUrl.length() < 1) { Intent i = new Intent(); i.setClass(this, PrefsActivity.class); startActivity(i); finish(); return; } else { server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); } } resetConnection(); mHttpState = new HttpState(); setContentView(R.layout.main); mPreview = (SurfaceView) findViewById(R.id.preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); this.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); setTorchMode(useTorch); } }, new IntentFilter("android.intent.action.REMOTE_EYES_COMMAND")); }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.OrgDetail.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.org_detail); orgName = null;//from w w w. jav a 2s . c o m Intent i = this.getIntent(); Bundle b = i.getExtras(); if (b != null) { orgName = b.getString(Orgs.O_NAME); organization_lid = b.getString(Orgs.O_LID); organization_gidh = b.getString(Orgs.O_GIDH); organization_position = b.getInt(Orgs.O_ID); } org = D_Organization.getOrgByLID(organization_lid, true, false); if (org == null) { Toast.makeText(this, "Organization not found!", Toast.LENGTH_SHORT).show(); return; } orgNameTextView = (TextView) findViewById(R.id.org_name_display_on_org_detail); orgNameTextView.setText(orgName); motion = (ImageView) findViewById(R.id.motion_img); constituent = (ImageView) findViewById(R.id.constituent_img); set = (ImageView) findViewById(R.id.org_set_img); profile = (ImageView) findViewById(R.id.org_profile_img); news = (ImageView) findViewById(R.id.news_img); if (org.getNamesConstituent() != null && org.getNamesConstituent().length > 0) { TextView orgDetailConstituentTextView = (TextView) findViewById(R.id.constituent_icon_text); orgDetailConstituentTextView.setText(org.getNamesConstituent()[0]); } if (org.getNamesMotion() != null && org.getNamesMotion().length > 0) { TextView orgDetailMotionTextView = (TextView) findViewById(R.id.motion_icon_text); orgDetailMotionTextView.setText(org.getNamesMotion()[0]); } motion.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(OrgDetail.this, Motion.class); Bundle b = new Bundle(); b.putInt(Orgs.O_ID, organization_position); b.putString(Orgs.O_GIDH, organization_gidh); b.putString(Orgs.O_LID, organization_lid); b.putString(Orgs.O_NAME, orgName); intent.putExtras(b); startActivity(intent); } }); constituent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); //intent.setClass(OrgDetail.this, Constituent.class); intent.setClass(OrgDetail.this, ConstituentFurtherLayer.class); Bundle b = new Bundle(); b.putInt(Orgs.O_ID, organization_position); b.putString(Orgs.O_GIDH, organization_gidh); b.putString(Orgs.O_LID, organization_lid); b.putString(Orgs.O_NAME, orgName); intent.putExtras(b); startActivity(intent); } }); set.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(OrgDetail.this, OrgSetCategoryName.class); startActivity(intent); } }); profile.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(OrgDetail.this, OrgProfile.class); Bundle b = new Bundle(); b.putInt(Orgs.O_ID, organization_position); b.putString(Orgs.O_GIDH, organization_gidh); b.putString(Orgs.O_LID, organization_lid); b.putString(Orgs.O_NAME, orgName); intent.putExtras(b); startActivity(intent); } }); news.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(OrgDetail.this, News.class); Bundle b = new Bundle(); b.putInt(Orgs.O_ID, organization_position); b.putString(Orgs.O_GIDH, organization_gidh); b.putString(Orgs.O_LID, organization_lid); b.putString(Orgs.O_NAME, orgName); intent.putExtras(b); startActivity(intent); } }); }
From source file:com.android.settings.beanstalk.service.AlarmService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { try {/*from ww w.j a v a 2s .co m*/ startAlarmSound(); } catch (Exception e) { // Do nothing } Bundle extras = intent.getExtras(); String names = extras.getString("number"); String title = getResources().getString(R.string.quiet_hours_alarm_dialog_title); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_quiethours); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setTicker(title) .setContentTitle(title).setContentText(names).setAutoCancel(false).setOngoing(true) .setSmallIcon(R.drawable.ic_quiethours).setLargeIcon(bm) .setStyle(new NotificationCompat.BigTextStyle() .bigText(names + getResources().getString(R.string.quiet_hours_alarm_message))); Intent alarmDialog = new Intent(); alarmDialog.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); alarmDialog.setClass(this, com.android.settings.beanstalk.service.BypassAlarm.class); alarmDialog.putExtra("number", names); alarmDialog.putExtra("norun", true); PendingIntent result = PendingIntent.getActivity(this, 0, alarmDialog, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(result); mManager.notify(NOTI_ID, builder.build()); return START_STICKY; }
From source file:com.android.settings.service.AlarmService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { try {//from w w w . j a va 2 s. co m startAlarmSound(); } catch (Exception e) { // Do nothing } Bundle extras = intent.getExtras(); String names = extras.getString("number"); String title = getResources().getString(R.string.quiet_hours_alarm_dialog_title); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_quiethours); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setTicker(title) .setContentTitle(title).setContentText(names).setAutoCancel(false).setOngoing(true) .setSmallIcon(R.drawable.ic_quiethours).setLargeIcon(bm) .setStyle(new NotificationCompat.BigTextStyle() .bigText(names + getResources().getString(R.string.quiet_hours_alarm_message))); Intent alarmDialog = new Intent(); alarmDialog.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); alarmDialog.setClass(this, com.android.settings.service.BypassAlarm.class); alarmDialog.putExtra("number", names); alarmDialog.putExtra("norun", true); PendingIntent result = PendingIntent.getActivity(this, 0, alarmDialog, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(result); mManager.notify(NOTI_ID, builder.build()); return START_STICKY; }
From source file:com.android.settings.slim.service.AlarmService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { try {/* w w w . j a va 2s .c o m*/ startAlarmSound(); } catch (Exception e) { // Do nothing } Bundle extras = intent.getExtras(); String names = extras.getString("number"); String title = getResources().getString(R.string.quiet_hours_alarm_dialog_title); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_quiethours); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setTicker(title) .setContentTitle(title).setContentText(names).setAutoCancel(false).setOngoing(true) .setSmallIcon(R.drawable.ic_quiethours).setLargeIcon(bm) .setStyle(new NotificationCompat.BigTextStyle() .bigText(names + getResources().getString(R.string.quiet_hours_alarm_message))); Intent alarmDialog = new Intent(); alarmDialog.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); alarmDialog.setClass(this, com.android.settings.slim.service.BypassAlarm.class); alarmDialog.putExtra("number", names); alarmDialog.putExtra("norun", true); PendingIntent result = PendingIntent.getActivity(this, 0, alarmDialog, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(result); mManager.notify(NOTI_ID, builder.build()); return START_STICKY; }
From source file:com.oddsoft.tpetrash2.view.activity.MainActivity.java
private void gotoCustomMapActivity(String mapType) { Intent intent = new Intent(); intent.setClass(MainActivity.this, CustomMapActivity.class); Bundle bundle = new Bundle(); bundle.putString("mapType", mapType); intent.putExtras(bundle);//from w w w . j a v a 2 s . c o m startActivity(intent); }
From source file:com.smile.moment.ui.activity.NightChatActivity.java
private void init() { int source = getIntent().getIntExtra(Constants.EXTRA_SOURCE_ID, 1); String title = "?"; String url = ApiUtil.MOMENT_NIGHT_CHAT; String docsId = "S1426235992757"; switch (source) { case Constants.SOURCE_FOR_NIGHT_CHAT: title = "?"; url = ApiUtil.MOMENT_NIGHT_CHAT; docsId = "S1426235992757"; break;// w w w . j a va 2 s. c o m case Constants.SOURCE_FOR_DRIVER_STUDY: title = "??"; url = ApiUtil.MOMENT_DRIVER_STUDY; docsId = "S1460094273198"; break; case Constants.SOURCE_FOR_GAME: title = "??"; url = ApiUtil.MOMENT_GAME; docsId = "S1426237757194"; break; case Constants.SOURCE_FOR_TODAY_VOICE: title = ""; url = ApiUtil.MOMENT_TODAY_VOICE; docsId = "S1426233520789"; break; case Constants.SOURCE_FOR_SEVEN_NEWS: title = "7"; url = ApiUtil.MOMENT_SEVEN_NEWS; docsId = "S1426238687771"; break; case Constants.SOURCE_FOR_FAT_CHAT: title = ""; url = ApiUtil.MOMENT_FAT_CHAT; docsId = "S1426235566308"; break; case Constants.SOURCE_FOR_UP: title = "?"; url = ApiUtil.MOMENT_UP; docsId = "S1449617711090"; break; } setToolBar(toolbar, title); loadingView.setHideBottom(); toolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { recyclerView.post(new Runnable() { @Override public void run() { recyclerView.smoothScrollToPosition(0); } }); } }); activity = this; context = activity.getApplicationContext(); list = new ArrayList<>(); refreshLayout.setColorSchemeResources(R.color.loading_color); final String finalUrl = url; final String finalDocsId = docsId; refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { getBooks(null, false, finalUrl, finalDocsId); } }); DividerDecoration.Builder builder = new DividerDecoration.Builder(context); builder.setColorResource(R.color.divider_color).setHeight(1f).setLeftPadding(R.dimen.divider_padding_left); recyclerView.addItemDecoration(builder.build()); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setLayoutManager(new LinearLayoutManager(activity)); adapter = new BooksAdapter(activity, list); recyclerView.setAdapter(adapter); helper = new ItemTouchHelper(new SimpleItemTouchHelperCallback(adapter, ItemTouchHelper.START)); helper.attachToRecyclerView(recyclerView); loadingView.setLoading(); loadingView.setOnReLoadListener(new View.OnClickListener() { @Override public void onClick(View v) { loadingView.setLoading(); getBooks(loadingView, false, finalUrl, finalDocsId); } }); adapter.setOnItemClickListener(new BooksAdapter.OnItemClickListener() { @Override public void onItemClick(int position) { Intent intent = new Intent(); intent.setClass(activity, ImageActivity.class); intent.putExtra(Constants.EXTRA_DOCS_ID, list.get(position).getDocid()); startActivity(intent); } }); getBooks(loadingView, false, url, docsId); }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.Motion.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.add_new_motion: Toast.makeText(this, "add a new Motion", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.setClass(this, AddMotion.class); startActivity(intent);/*from w w w . ja v a2 s. c o m*/ /* // Respond to the action bar's Up/Home button case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; */ } return super.onOptionsItemSelected(item); }
From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java
@Override public void keyShareCommand(String key) { Intent intent = new Intent(); switch (key) { case "keyshare": intent.setClass(LockActivity.this, KeyShareActivity.class); startActivityForResult(intent, 0); break;/*from w ww .j av a 2 s . c om*/ case "keychange": try { ServerNode.requestRemoteCredentials(); requestProgress = ProgressDialog.show(LockActivity.this, "", "Retrieving keys...", true); requestProgress.setCancelable(true); requestProgress.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // TODO: ? } }); startRequest(); } catch (Exception e) { e.printStackTrace(); } break; } }