List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:de.blinkt.openvpn.ActivityDashboard.java
public void handleMessage(Message msg) { Bundle data = msg.getData();//from w w w. j a va2s. com switch (msg.what) { case RemoteAPI.MessageType: { String method = data.getString("method"); String code = data.getString("code"); String message = data.getString("message"); if (method.equalsIgnoreCase("getUserServices")) { m_waitdlg.cancel(); if (!(code.equalsIgnoreCase("0") || code.equalsIgnoreCase("4") || code.equalsIgnoreCase("5"))) { Toast toast = Toast.makeText(this, "getUserServices failed, " + message, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } m_package = data.getString("packages"); m_username = data.getString("username"); m_password = data.getString("vpnpassword"); // update login password to vpnpassword. updatePackage(m_package.trim()); } break; } // case VpnStatus.StateListener: { // String log = data.getString("log"); // if(log == null) // return; // // get openvpn state from the log. // if(log.contains("AUTH_FAILED")) { // Toast toast = Toast.makeText(this, "Username or password error.", Toast.LENGTH_SHORT); // toast.setGravity(Gravity.CENTER, 0, 0); // toast.show(); // setStatus(Status.Disconnected); // return; // } // if(log.contains("SIGTERM") || log.contains("exiting")) { // Toast toast = Toast.makeText(this, "Disconnected from server.", Toast.LENGTH_SHORT); // toast.setGravity(Gravity.CENTER, 0, 0); // toast.show(); // // setStatus(Status.Disconnected); // return; // } // if(log.contains("Initialization Sequence Completed")) { // if(m_status == Status.Connecting) // setStatus(Status.Connected); // return; // } // break; } case HandlerDialogClickListener.MessageType: { switch (msg.arg1) { case AlertDialogExitNotify: { switch (msg.arg2) { case AlertDialog.BUTTON_POSITIVE: { Intent intent = new Intent(); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent); break; } case AlertDialog.BUTTON_NEGATIVE: { break; } case AlertDialog.BUTTON_NEUTRAL: { if (VpnStatus.isVPNActive()) { if (mService != null) { try { mService.stopVPN(false); } catch (RemoteException e) { VpnStatus.logException(e); } } } setStatus(Status.Disconnected); finish(); break; } } break; } } break; } case NetDisconnectedNotify: { Log.d("ibVPN", "Disconnected by internet lose."); Toast toast = Toast.makeText(this, "VPN connection was lost, please reconnect Wi-Fi/Mobile Data connection.", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Button button = (Button) findViewById(R.id.button_dashboard_connect); if (button.getText().toString().equalsIgnoreCase(getString(R.string.text_cancel))) { // m_openvpn.cancel(); setStatus(Status.Disconnected); } else if (button.getText().toString().equalsIgnoreCase(getString(R.string.text_disconnect))) { // m_openvpn.disconnect(); setStatus(Status.Disconnected); } break; } default: { Log.d("ibVPN", "Message From Unknown Thread. :)"); break; } } }
From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java
public final void exitBrowser() { if (mSipBranch) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent);/*from w w w . j av a 2s . c o m*/ return; } if (null != mBrowser) { mBrowser.onAppStop(); } mBrowserAround.removeViewImmediate(); clean(); finish(); }
From source file:com.example.android.home.Home.java
/** * Loads the list of installed applications in mApplications. *///from w w w .ja va 2s .com private void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } PackageManager manager = getPackageManager(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); for (int i = 0; i < count; i++) { //for (int i = 0; i < 6; i++) { // show only 6 apps ApplicationInfo application = new ApplicationInfo(); ResolveInfo info = apps.get(i); application.title = info.loadLabel(manager); application.setActivity( new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); Log.v("Home APP", "package neme= " + info.activityInfo.applicationInfo.packageName); Log.v("Home APP", "neme= " + info.activityInfo.name); Log.v("Home APP", "title= " + application.title); application.icon = info.activityInfo.loadIcon(manager); // TODO // Replace Icons //if((application.title+"").equals("Calculator")) application.icon = getResources().getDrawable(R.drawable.ic_launcher_home_big); // Add Application if ((application.title + "").equals("Browser")) mApplications.add(application); if ((application.title + "").equals("Phone")) mApplications.add(application); if ((application.title + "").equals("People")) mApplications.add(application); if ((application.title + "").equals("Messaging")) mApplications.add(application); if ((application.title + "").equals("Settings")) mApplications.add(application); } // Took from http://hi-android.info/src/index.html // ********************* ADD Call Log ApplicationInfo application = new ApplicationInfo(); application.title = "Call Log"; application.icon = getResources().getDrawable(R.drawable.ic_launcher_home); application.setActivity( new ComponentName("com.android.contacts", "com.android.contacts.RecentCallsListActivity"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); mApplications.add(application); } }
From source file:com.linkbubble.util.Util.java
static public String getDefaultLauncherPackage(PackageManager packageManager) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); ResolveInfo resolveInfo = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfo != null && resolveInfo.activityInfo != null) { if (resolveInfo.activityInfo.packageName.equals("android") == false) { //setDefaultLauncherPreference.setSummary(R.string.not_default_youtube_app); return resolveInfo.activityInfo.packageName; }//w w w . java2 s .c o m } return null; }
From source file:net.ustyugov.jtalk.Notify.java
public static void incomingFileProgress(String filename, Status status) { JTalkService service = JTalkService.getInstance(); Intent i = new Intent(service, RosterActivity.class); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_LAUNCHER); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(service, 0, i, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(service); mBuilder.setContentTitle(filename);/*www .j ava2s .c om*/ mBuilder.setContentIntent(contentIntent); if (status == Status.complete) { mBuilder.setSmallIcon(android.R.drawable.stat_sys_download_done); mBuilder.setTicker(service.getString(R.string.Completed)); mBuilder.setContentText(service.getString(R.string.Completed)); mBuilder.setAutoCancel(true); mBuilder.setOngoing(false); } else if (status == Status.cancelled) { mBuilder.setSmallIcon(android.R.drawable.stat_sys_warning); mBuilder.setTicker(service.getString(R.string.Canceled)); mBuilder.setContentText(service.getString(R.string.Canceled)); mBuilder.setAutoCancel(true); mBuilder.setOngoing(false); } else if (status == Status.refused) { mBuilder.setSmallIcon(android.R.drawable.stat_sys_warning); mBuilder.setTicker(service.getString(R.string.Canceled)); mBuilder.setContentText(service.getString(R.string.Canceled)); mBuilder.setAutoCancel(true); mBuilder.setOngoing(false); } else if (status == Status.negotiating_transfer) { mBuilder.setOngoing(true); mBuilder.setSmallIcon(android.R.drawable.stat_sys_download_done); mBuilder.setTicker(service.getString(R.string.Waiting)); mBuilder.setContentText(service.getString(R.string.Waiting)); } else if (status == Status.in_progress) { mBuilder.setOngoing(true); mBuilder.setSmallIcon(android.R.drawable.stat_sys_download); mBuilder.setTicker(service.getString(R.string.Downloading)); mBuilder.setContentText(service.getString(R.string.Downloading)); } else if (status == Status.error) { mBuilder.setSmallIcon(android.R.drawable.stat_sys_warning); mBuilder.setTicker(service.getString(R.string.Error)); mBuilder.setContentText(service.getString(R.string.Error)); mBuilder.setAutoCancel(true); mBuilder.setOngoing(false); } else { return; } NotificationManager mng = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE); mng.notify(NOTIFICATION_IN_FILE, mBuilder.build()); }
From source file:com.github.dfa.diaspora_android.activity.MainActivity.java
/** * Handle intents and execute intent specific actions * * @param intent intent to get handled/* www . jav a 2 s .c om*/ */ private void handleIntent(Intent intent) { AppLog.i(this, "handleIntent()"); if (intent == null) { AppLog.v(this, "Intent was null"); return; } String action = intent.getAction(); String type = intent.getType(); String loadUrl = null; AppLog.v(this, "Action: " + action + " Type: " + type); if (Intent.ACTION_MAIN.equals(action)) { loadUrl = urls.getStreamUrl(); } else if (ACTION_OPEN_URL.equals(action)) { loadUrl = intent.getStringExtra(URL_MESSAGE); } else if (Intent.ACTION_VIEW.equals(action) && intent.getDataString() != null) { Uri data = intent.getData(); if (data != null && data.toString().startsWith(CONTENT_HASHTAG)) { handleHashtag(intent); return; } else { loadUrl = intent.getDataString(); AppLog.v(this, "Intent has a delicious URL for us: " + loadUrl); } } else if (ACTION_CHANGE_ACCOUNT.equals(action)) { AppLog.v(this, "Reset pod data and show PodSelectionFragment"); appSettings.setPod(null); runOnUiThread(new Runnable() { public void run() { navheaderTitle.setText(R.string.app_name); navheaderDescription.setText(R.string.app_subtitle); navheaderImage.setImageResource(R.drawable.ic_launcher); app.resetPodData( ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView()); } }); showFragment(getFragment(PodSelectionFragment.TAG)); } else if (ACTION_CLEAR_CACHE.equals(action)) { AppLog.v(this, "Clear WebView cache"); runOnUiThread(new Runnable() { public void run() { ContextMenuWebView wv = ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)) .getWebView(); if (wv != null) { wv.clearCache(true); } } }); } else if (Intent.ACTION_SEND.equals(action) && type != null) { switch (type) { case "text/plain": if (intent.hasExtra(Intent.EXTRA_SUBJECT)) { handleSendSubject(intent); } else { handleSendText(intent); } break; case "image/*": handleSendImage(intent); //TODO: Add intent filter to Manifest and implement method break; } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { /* TODO: Implement and add filter to manifest */ return; } //Catch split screen recreation if (action != null && action.equals(Intent.ACTION_MAIN) && getTopFragment() != null) { return; } if (loadUrl != null) { navDrawer.closeDrawers(); openDiasporaUrl(loadUrl); } }
From source file:com.pvo.activity.MainFragmentActivity.java
@Override public void onBackPressed() { if (fragmentStack.size() > 1) { System.out.println("--> On back press if condition <---"); FragmentTransaction ft = fragmentManager.beginTransaction(); if (ft != null) { fragmentStack.lastElement().onPause(); ft.remove(fragmentStack.pop()); Fragment lastFragment = fragmentStack.lastElement(); lastFragment.onResume();/*from w w w .ja v a 2s .c o m*/ ft.show(lastFragment); ft.commit(); } } else { System.out.println("--> On back press else condition <---"); Fragment visible = getVisibleFragment(); if (visible instanceof ZNotificationMainFragment) { clearStoreData(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { redirectToNotificaiton(); } } }
From source file:com.first.akashshrivastava.showernow.ShowerActivity.java
@Override public void onBackPressed() { //if back is pressed the application closes Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);//from w w w . j a va2 s .c o m }
From source file:com.example.yuen.e_carei.ShowAppointmentList.java
private void open(ApplicationInfo item) { // open app// w w w.j a va 2 s .c om Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(item.packageName); List<ResolveInfo> resolveInfoList = getPackageManager().queryIntentActivities(resolveIntent, 0); if (resolveInfoList != null && resolveInfoList.size() > 0) { ResolveInfo resolveInfo = resolveInfoList.get(0); String activityPackageName = resolveInfo.activityInfo.packageName; String className = resolveInfo.activityInfo.name; Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName componentName = new ComponentName(activityPackageName, className); intent.setComponent(componentName); startActivity(intent); } }
From source file:com.pdmanager.views.patient.TechnicianActivity.java
@Override public void onMessageReceived(final CNMessage cnMessage) { if (application.getUniqueId().equals(cnMessage.getUniqueId())) { return;//from w w w .j a v a2 s .c o m } if (cnMessage.getMessageType() == CNMessage.CNMessageType.Calling) { if (application.isInConference()) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.Busy, null); return; } callDialog = new AlertDialog.Builder(this).create(); LayoutInflater inflater = getLayoutInflater(); View incomingCallDialog = inflater.inflate(R.layout.incoming_call_dialog, null); incomingCallDialog.setAlpha(0.5f); callDialog.setView(incomingCallDialog); TextView caller = (TextView) incomingCallDialog.findViewById(R.id.caller); caller.setText(cnMessage.getDisplayName()); Button answerButton = (Button) incomingCallDialog.findViewById(R.id.answer_button); answerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.setConferenceId(cnMessage.getConferenceId()); application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerAccept, null); callDialog.hide(); currentRingtone.stop(); Intent intent = new Intent(application.getContext(), TechnicianActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); application.join(application.getConferenceId(), true); } }); Button declineButton = (Button) incomingCallDialog.findViewById(R.id.decline_button); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerDecline, null); currentRingtone.stop(); callDialog.hide(); } }); callDialog.setCancelable(false); callDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //play current Ringtone currentRingtone.play(); callDialog.show(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.Cancel) { currentRingtone.stop(); callDialog.hide(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.EndCall) { if (application.leave()) { int count = getFragmentManager().getBackStackEntryCount(); String name = getFragmentManager().getBackStackEntryAt(count - 2).getName(); getFragmentManager().popBackStack(name, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } }