List of usage examples for android.content Intent FLAG_ACTIVITY_PREVIOUS_IS_TOP
int FLAG_ACTIVITY_PREVIOUS_IS_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_PREVIOUS_IS_TOP.
Click Source Link
From source file:com.vuze.android.remote.RemoteUtils.java
public static void openRemote(Activity activity, RemoteProfile remoteProfile, boolean isMain) { AppPreferences appPreferences = VuzeRemoteApp.getAppPreferences(); if (appPreferences.getRemote(remoteProfile.getID()) == null) { appPreferences.addRemoteProfile(remoteProfile); }/*from ww w . j a va 2 s. c o m*/ Intent myIntent = new Intent(activity.getIntent()); myIntent.setAction(Intent.ACTION_VIEW); myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); if (isMain) { myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Scenario: // User has multiple remote hosts. // User clicks on torrent link in browser. // User is displayed remote selector activity (IntenntHandler) and picks // Remote activity is opened, torrent is added // We want the back button to go back to the browser. Going back to // the remote selector would be confusing (especially if they then chose // another remote!) myIntent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); } myIntent.setClass(activity, TorrentViewActivity.class); myIntent.putExtra(SessionInfoManager.BUNDLE_KEY, remoteProfile.getID()); activity.startActivity(myIntent); }
From source file:com.aokyu.dev.pocket.PocketClient.java
private void continueAuthorization(Activity callback, RequestToken requestToken) { String url = PocketServer.getRedirectUrl(mConsumerKey, requestToken); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); callback.startActivity(intent);/*from w w w . ja va 2s. co m*/ }
From source file:de.lespace.apprtc.ConnectChatActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_connect); // Get setting keys. PreferenceManager.setDefaultValues(this, R.xml.preferences, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); missingPermissions = new ArrayList(); for (String permission : MANDATORY_PERMISSIONS) { if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { missingPermissions.add(permission); }// w w w . jav a2 s . c o m } requestPermission(); //Bring Call2Front when bringToFrontBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Intent intentStart = new Intent(getApplicationContext(), ConnectChatActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); startActivity(intentStart); // newFragment.show(transaction,"loading"); // showDialog(); } }; registerBringToFrontReceiver(); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } ImageButton connectButton = (ImageButton) findViewById(R.id.connect_button); connectButton.setOnClickListener(connectListener); // If an implicit VIEW intent is launching the app, go directly to that URL. //final Intent intent = getIntent(); Uri wsurl = Uri.parse(Configs.ROOM_URL); //intent.getData(); Log.d(TAG, "connecting to:" + wsurl.toString()); if (wsurl == null) { logAndToast(getString(R.string.missing_wsurl)); Log.e(TAG, "Didn't get any URL in intent!"); setResult(RESULT_CANCELED); finish(); return; } if (from == null || from.length() == 0) { logAndToast(getString(R.string.missing_from)); Log.e(TAG, "Incorrect from in intent!"); setResult(RESULT_CANCELED); finish(); return; } roomConnectionParameters = new AppRTCClient.RoomConnectionParameters(wsurl.toString(), from, false); Log.i(TAG, "creating appRtcClient with roomUri:" + wsurl.toString() + " from:" + from); // Create connection client and connection parameters. appRtcClient = new WebSocketRTCClient(this, new LooperExecutor()); connectToWebsocket(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. }
From source file:com.vuze.android.remote.activity.IntentHandler.java
private boolean handleIntent(Intent intent, Bundle savedInstanceState) { boolean forceProfileListOpen = (intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) > 0; if (AndroidUtils.DEBUG) { Log.d(TAG, "ForceOpen? " + forceProfileListOpen); Log.d(TAG, "IntentHandler intent = " + intent); }/*from w w w .j a va 2 s .c om*/ appPreferences = VuzeRemoteApp.getAppPreferences(); Uri data = intent.getData(); if (data != null) { try { // check for vuze://remote//* String scheme = data.getScheme(); String host = data.getHost(); String path = data.getPath(); if ("vuze".equals(scheme) && "remote".equals(host) && path != null && path.length() > 1) { String ac = path.substring(1); if (AndroidUtils.DEBUG) { Log.d(TAG, "got ac '" + ac + "' from " + data); } intent.setData(null); if (ac.equals("cmd=advlogin")) { DialogFragmentGenericRemoteProfile dlg = new DialogFragmentGenericRemoteProfile(); AndroidUtils.showDialog(dlg, getSupportFragmentManager(), "GenericRemoteProfile"); forceProfileListOpen = true; } else if (ac.length() < 100) { RemoteProfile remoteProfile = new RemoteProfile("vuze", ac); new RemoteUtils(this).openRemote(remoteProfile, true); finish(); return true; } } // check for http[s]://remote.vuze.com/ac=* if (host != null && host.equals("remote.vuze.com") && data.getQueryParameter("ac") != null) { String ac = data.getQueryParameter("ac"); if (AndroidUtils.DEBUG) { Log.d(TAG, "got ac '" + ac + "' from " + data); } intent.setData(null); if (ac.length() < 100) { RemoteProfile remoteProfile = new RemoteProfile("vuze", ac); new RemoteUtils(this).openRemote(remoteProfile, true); finish(); return true; } } } catch (Exception e) { if (AndroidUtils.DEBUG) { e.printStackTrace(); } } } if (!forceProfileListOpen) { int numRemotes = getRemotesWithLocal().length; if (numRemotes == 0) { // New User: Send them to Login (Account Creation) Intent myIntent = new Intent(Intent.ACTION_VIEW, null, this, LoginActivity.class); myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); startActivity(myIntent); finish(); return true; } else if (numRemotes == 1 || intent.getData() == null) { try { RemoteProfile remoteProfile = appPreferences.getLastUsedRemote(); if (remoteProfile != null) { if (savedInstanceState == null) { new RemoteUtils(this).openRemote(remoteProfile, true); finish(); return true; } } else { Log.d(TAG, "Has Remotes, but no last remote"); } } catch (Throwable t) { if (AndroidUtils.DEBUG) { Log.e(TAG, "onCreate", t); } VuzeEasyTracker.getInstance(this).logError(t); } } } return false; }
From source file:de.lespace.apprtc.ConnectActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_connect); // Get setting keys. PreferenceManager.setDefaultValues(this, R.xml.preferences, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); keyprefFrom = getString(R.string.pref_from_key); keyprefVideoCallEnabled = getString(R.string.pref_videocall_key); keyprefResolution = getString(R.string.pref_resolution_key); keyprefFps = getString(R.string.pref_fps_key); keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key); keyprefVideoBitrateType = getString(R.string.pref_startvideobitrate_key); keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key); keyprefVideoCodec = getString(R.string.pref_videocodec_key); keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key); keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key); keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key); keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key); keyprefAudioCodec = getString(R.string.pref_audiocodec_key); keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key); keyprefAecDump = getString(R.string.pref_aecdump_key); keyprefOpenSLES = getString(R.string.pref_opensles_key); keyprefDisplayHud = getString(R.string.pref_displayhud_key); keyprefTracing = getString(R.string.pref_tracing_key); keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key); keyprefRoom = getString(R.string.pref_room_key); keyprefRoomList = getString(R.string.pref_room_list_key); from = sharedPref.getString(keyprefFrom, getString(R.string.pref_from_default)); // String roomUrl = sharedPref.getString( // keyprefRoomServerUrl, getString(R.string.pref_room_server_url_default)); // Video call enabled flag. boolean videoCallEnabled = sharedPref.getBoolean(keyprefVideoCallEnabled, Boolean.valueOf(getString(R.string.pref_videocall_default))); // Get default codecs. String videoCodec = sharedPref.getString(keyprefVideoCodec, getString(R.string.pref_videocodec_default)); String audioCodec = sharedPref.getString(keyprefAudioCodec, getString(R.string.pref_audiocodec_default)); // Check HW codec flag. boolean hwCodec = sharedPref.getBoolean(keyprefHwCodecAcceleration, Boolean.valueOf(getString(R.string.pref_hwcodec_default))); // Check Capture to texture. boolean captureToTexture = sharedPref.getBoolean(keyprefCaptureToTexture, Boolean.valueOf(getString(R.string.pref_capturetotexture_default))); // Check Disable Audio Processing flag. boolean noAudioProcessing = sharedPref.getBoolean(keyprefNoAudioProcessingPipeline, Boolean.valueOf(getString(R.string.pref_noaudioprocessing_default))); // Check Disable Audio Processing flag. boolean aecDump = sharedPref.getBoolean(keyprefAecDump, Boolean.valueOf(getString(R.string.pref_aecdump_default))); // Check OpenSL ES enabled flag. boolean useOpenSLES = sharedPref.getBoolean(keyprefOpenSLES, Boolean.valueOf(getString(R.string.pref_opensles_default))); // Check for mandatory permissions. int counter = 0; missingPermissions = new ArrayList(); for (String permission : MANDATORY_PERMISSIONS) { if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { counter++;/*from w ww. j av a 2s . c o m*/ missingPermissions.add(permission); } } requestPermission(); // mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); gcmRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { logAndToast(getString(R.string.gcm_send_message)); // mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { logAndToast(getString(R.string.gcm_send_message)); // mInformationTextView.setText(getString(R.string.token_error_message)); } } }; //Bring Call2Front when bringToFrontBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Intent intentStart = new Intent(getApplicationContext(), ConnectActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); startActivity(intentStart); // newFragment.show(transaction,"loading"); // showDialog(); } }; // Registering BroadcastReceiver registerGCMReceiver(); registerBringToFrontReceiver(); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } // Get video resolution from settings. int videoWidth = 0; int videoHeight = 0; String resolution = sharedPref.getString(keyprefResolution, getString(R.string.pref_resolution_default)); String[] dimensions = resolution.split("[ x]+"); if (dimensions.length == 2) { try { videoWidth = Integer.parseInt(dimensions[0]); videoHeight = Integer.parseInt(dimensions[1]); } catch (NumberFormatException e) { videoWidth = 0; videoHeight = 0; Log.e(TAG, "Wrong video resolution setting: " + resolution); } } // Get camera fps from settings. int cameraFps = 0; String fps = sharedPref.getString(keyprefFps, getString(R.string.pref_fps_default)); String[] fpsValues = fps.split("[ x]+"); if (fpsValues.length == 2) { try { cameraFps = Integer.parseInt(fpsValues[0]); } catch (NumberFormatException e) { Log.e(TAG, "Wrong camera fps setting: " + fps); } } // Check capture quality slider flag. boolean captureQualitySlider = sharedPref.getBoolean(keyprefCaptureQualitySlider, Boolean.valueOf(getString(R.string.pref_capturequalityslider_default))); // Get video and audio start bitrate. int videoStartBitrate = 0; String bitrateTypeDefault = getString(R.string.pref_startvideobitrate_default); String bitrateType = sharedPref.getString(keyprefVideoBitrateType, bitrateTypeDefault); if (!bitrateType.equals(bitrateTypeDefault)) { String bitrateValue = sharedPref.getString(keyprefVideoBitrateValue, getString(R.string.pref_startvideobitratevalue_default)); videoStartBitrate = Integer.parseInt(bitrateValue); } int audioStartBitrate = 0; bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default); bitrateType = sharedPref.getString(keyprefAudioBitrateType, bitrateTypeDefault); if (!bitrateType.equals(bitrateTypeDefault)) { String bitrateValue = sharedPref.getString(keyprefAudioBitrateValue, getString(R.string.pref_startaudiobitratevalue_default)); audioStartBitrate = Integer.parseInt(bitrateValue); } // Check statistics display option. boolean displayHud = sharedPref.getBoolean(keyprefDisplayHud, Boolean.valueOf(getString(R.string.pref_displayhud_default))); boolean tracing = sharedPref.getBoolean(keyprefTracing, Boolean.valueOf(getString(R.string.pref_tracing_default))); Log.d(TAG, "Connecting from " + from + " at URL " + Configs.ROOM_URL); if (validateUrl(Configs.ROOM_URL)) { Uri uri = Uri.parse(Configs.ROOM_URL); intent = new Intent(this, ConnectActivity.class); intent.setData(uri); intent.putExtra(CallActivity.EXTRA_VIDEO_CALL, videoCallEnabled); intent.putExtra(CallActivity.EXTRA_VIDEO_WIDTH, videoWidth); intent.putExtra(CallActivity.EXTRA_VIDEO_HEIGHT, videoHeight); intent.putExtra(CallActivity.EXTRA_VIDEO_FPS, cameraFps); intent.putExtra(CallActivity.EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED, captureQualitySlider); intent.putExtra(CallActivity.EXTRA_VIDEO_BITRATE, videoStartBitrate); intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, videoCodec); intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec); intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, captureToTexture); intent.putExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED, noAudioProcessing); intent.putExtra(CallActivity.EXTRA_AECDUMP_ENABLED, aecDump); intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES); intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate); intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec); intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud); intent.putExtra(CallActivity.EXTRA_TRACING, tracing); intent.putExtra(CallActivity.EXTRA_CMDLINE, commandLineRun); intent.putExtra(CallActivity.EXTRA_RUNTIME, runTimeMs); } roomListView = (ListView) findViewById(R.id.room_listview); roomListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); connectButton = (ImageButton) findViewById(R.id.connect_button); connectButton.setOnClickListener(connectListener); // If an implicit VIEW intent is launching the app, go directly to that URL. //final Intent intent = getIntent(); Uri wsurl = Uri.parse(Configs.ROOM_URL); //intent.getData(); Log.d(TAG, "connecting to:" + wsurl.toString()); if (wsurl == null) { logAndToast(getString(R.string.missing_wsurl)); Log.e(TAG, "Didn't get any URL in intent!"); setResult(RESULT_CANCELED); finish(); return; } if (from == null || from.length() == 0) { logAndToast(getString(R.string.missing_from)); Log.e(TAG, "Incorrect from in intent!"); setResult(RESULT_CANCELED); finish(); return; } peerConnectionParameters = new PeerConnectionClient.PeerConnectionParameters(videoCallEnabled, tracing, videoWidth, videoHeight, cameraFps, videoStartBitrate, videoCodec, hwCodec, captureToTexture, audioStartBitrate, audioCodec, noAudioProcessing, aecDump, useOpenSLES); roomConnectionParameters = new AppRTCClient.RoomConnectionParameters(wsurl.toString(), from, false); Log.i(TAG, "creating appRtcClient with roomUri:" + wsurl.toString() + " from:" + from); // Create connection client and connection parameters. appRtcClient = new WebSocketRTCClient(this, new LooperExecutor()); connectToWebsocket(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); }
From source file:com.trellmor.berrytubechat.ChatActivity.java
private void loadPreferences() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); try {// www . j a va 2 s .c o m mScrollback = Integer.parseInt(settings.getString(MainActivity.KEY_SCROLLBACK, "100")); } catch (NumberFormatException e) { mScrollback = 100; } if (mScrollback <= 0) mScrollback = 100; if (mBinder != null) mBinder.getService().setChatMsgBufferSize(mScrollback); try { mFlair = Integer.parseInt(settings.getString(MainActivity.KEY_FLAIR, "0")); } catch (NumberFormatException e) { mFlair = 0; } if (settings.getBoolean(MainActivity.KEY_SQUEE, false)) { mNotification = new NotificationCompat.Builder(this); mNotification.setSmallIcon(R.drawable.ic_stat_notify_chat); mNotification.setLights(0xFF0000FF, 100, 2000); mNotification.setAutoCancel(true); Intent intent = new Intent(this, ChatActivity.class); intent.putExtra(MainActivity.KEY_USERNAME, mUsername); intent.putExtra(MainActivity.KEY_PASSWORD, mPassword); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY); mNotification.setContentIntent( PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); String squee = settings.getString(MainActivity.KEY_SQUEE_RINGTONE, ""); if (!"".equals(squee)) { mNotification.setSound(Uri.parse(squee), AudioManager.STREAM_NOTIFICATION); } if (settings.getBoolean(MainActivity.KEY_SQUEE_VIBRATE, false)) { mNotification.setVibrate(new long[] { 0, 100 }); } } else { mNotification = null; } boolean showVideo = settings.getBoolean(MainActivity.KEY_VIDEO, false); if (showVideo != mShowVideo) { // If the value has changed, act on it if (showVideo) { if (!mFirstPrefLoad) { Toast.makeText(this, R.string.toast_video_enabled, Toast.LENGTH_LONG).show(); } } else { mBinder.getService().disableVideoMessages(); setTextVideoVisible(false); } } mShowVideo = showVideo; mShowDrinkCount = settings.getBoolean(MainActivity.KEY_DRINKCOUNT, true); mPopupPoll = settings.getBoolean(MainActivity.KEY_POPUP_POLL, false); updateDrinkCount(); mFirstPrefLoad = false; }
From source file:com.nbplus.vbroadlauncher.HomeLauncherActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean isTablet = DisplayUtils.isTabletDevice(this); LauncherSettings.getInstance(this).setIsSmartPhone(!isTablet); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); setContentView(R.layout.activity_home_launcher); DeviceUtils.showDeviceInformation(); Log.d(TAG, ">>>DisplayUtils.getScreenDensity(this) = " + DisplayUtils.getScreenDensity(this)); // vitamio library load if (!LibsChecker.checkVitamioLibs(this)) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override/* w w w.j av a2 s .c om*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alert.setMessage(R.string.alert_media_message); alert.show(); return; } mCurrentLocale = getResources().getConfiguration().locale; if (BuildConfig.DEBUG) { Point p = DisplayUtils.getScreenSize(this); Log.d(TAG, "Screen size px = " + p.x + ", py = " + p.y); Point screen = p; p = DisplayUtils.getScreenDp(this); Log.d(TAG, "Screen dp x = " + p.x + ", y = " + p.y); int density = DisplayUtils.getScreenDensity(this); Log.d(TAG, "Screen density = " + density); } if (isTablet) { //is tablet Log.d(TAG, "Tablet"); } else { //is phone Log.d(TAG, "isTabletDevice() returns Phone.. now check display inches"); double diagonalInches = DisplayUtils.getDisplayInches(this); if (diagonalInches >= 6.4) { // 800x400 ? portrait ? 6.43 ? . // 6.5inch device or bigger Log.d(TAG, "DisplayUtils.getDisplayInches() bigger than 6.5"); } else { if (!Constants.OPEN_BETA_PHONE) { // smaller device Log.d(TAG, "DisplayUtils.getDisplayInches() smaller than 6.5"); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alert.setMessage(R.string.alert_phone_message); alert.show(); return; } } } if (!Constants.OPEN_BETA_PHONE || !LauncherSettings.getInstance(this).isSmartPhone()) { if (isMyLauncherDefault()) { Log.d(TAG, "isMyLauncherDefault() == true"); // fake home key event. Intent fakeIntent = new Intent(); fakeIntent.setAction(Intent.ACTION_MAIN); fakeIntent.addCategory(Intent.CATEGORY_HOME); fakeIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(fakeIntent); } else { Log.d(TAG, "Constants.OPEN_BETA_PHONE == false || isMyLauncherDefault() == false"); //resetPreferredLauncherAndOpenChooser(); } } // ? .. ? ? ?. // ? ?. IntentFilter filter = new IntentFilter(); filter.addAction(Constants.ACTION_LAUNCHER_ACTIVITY_RUNNING); filter.addAction(IoTConstants.ACTION_RECEIVE_EMERGENCY_CALL_DEVICE_BROADCAST); LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter); Intent intent = new Intent(Constants.ACTION_LAUNCHER_ACTIVITY_RUNNING); mActivityRunningTime = System.currentTimeMillis(); intent.putExtra(Constants.EXTRA_LAUNCHER_ACTIVITY_RUNNING, mActivityRunningTime); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); // set background image setContentViewByOrientation(); if (LauncherSettings.getInstance(this).getPreferredUserLocation() == null) { Location defaultLocation = new Location("stub"); defaultLocation.setLongitude(126.929810); defaultLocation.setLatitude(37.488201); LauncherSettings.getInstance(this).setPreferredUserLocation(defaultLocation); } // First we need to check availability of play services mResultReceiver = new AddressResultReceiver(mActivityHandler); // Set defaults, then update using values stored in the Bundle. mAddressRequested = false; mAddressOutput = null; // Update values using data stored in the Bundle. updateValuesFromBundle(savedInstanceState); /** * ? ??? ? . * ?? ? . */ mBroadcastFramelayout = (FrameLayout) findViewById(R.id.realtimeBroadcastFragment); if (mBroadcastFramelayout != null) { mBroadcastFramelayout.setVisibility(View.GONE); } FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Bundle bundle; // check installation or bind to service VBroadcastServer serverInfo = LauncherSettings.getInstance(this).getServerInformation(); if (serverInfo == null || !Constants.VBROAD_INITIAL_PAGE.equals(serverInfo.getInitialServerPage())) { // ? ?. // ? Registration ? . LauncherSettings.getInstance(this).setServerInformation(null); LauncherSettings.getInstance(this).setIsCompletedSetup(false); // open user register fragment RegisterFragment registerFragment = new RegisterFragment(); bundle = new Bundle(); registerFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, registerFragment); } else { if (LauncherSettings.getInstance(this).isCompletedSetup() == false) { LauncherSettings.getInstance(this).setServerInformation(null); // open user register fragment RegisterFragment registerFragment = new RegisterFragment(); bundle = new Bundle(); registerFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, registerFragment); } else { // open main launcher fragment LauncherFragment launcherFragment = new LauncherFragment(); bundle = new Bundle(); launcherFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, launcherFragment); } } fragmentTransaction.commit(); // initialize iot interface. String collectServerAddress = null; if (serverInfo != null) { String apiServer = serverInfo.getApiServer(); if (StringUtils.isEmptyString(apiServer)) { collectServerAddress = null; } else { collectServerAddress = apiServer + Constants.API_COLLECTED_IOT_DATA_CONTEXT; } } IoTResultCodes resCode = IoTInterface.getInstance().initialize(this, LauncherSettings.getInstance(this).getDeviceID(), collectServerAddress); if (!resCode.equals(IoTResultCodes.SUCCESS)) { if (resCode.equals(IoTResultCodes.BIND_SERVICE_FAILED)) { Toast.makeText(getApplicationContext(), "Bind IoT Service failed!!!", Toast.LENGTH_SHORT).show(); } } }
From source file:de.k3b.android.toGoZip.SettingsActivity.java
private boolean onCmdSend(CharSequence title) { ZipStorage storage = SettingsImpl.getCurrentZipStorage(this); Intent intent = new Intent(Intent.ACTION_SEND); Uri contentUri = Uri.parse(storage.getFullZipUriOrNull()); String mime = "application/zip"; intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); // EXTRA_CC, EXTRA_BCC // intent.putExtra(Intent.EXTRA_EMAIL, new String[]{toAddress}); intent.putExtra(Intent.EXTRA_SUBJECT, SettingsImpl.getZipFile()); // intent.putExtra(Intent.EXTRA_TEXT, body); intent.putExtra(Intent.EXTRA_STREAM, contentUri); intent.setType(mime);// w w w.java 2 s .c o m final String debugMessage = "SettingsActivity.onCmdSend(" + title + ", startActivity='" + intent.toUri(0) + "')"; try { final Intent chooser = Intent.createChooser(intent, title); chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); this.startActivity(chooser); if (Global.debugEnabled) { Log.d(Global.LOG_CONTEXT, debugMessage); } } catch (Exception ex) { Log.w(Global.LOG_CONTEXT, debugMessage, ex); } return true; }
From source file:com.trellmor.berrytubechat.ChatActivity.java
private void initService(BerryTubeBinder service) { mBinder = service;/* w w w. j a v a 2 s. c om*/ if (mCallback == null) { createCallback(); } mBinder.getService().setCallback(mCallback); mBinder.getService().setChatMsgBufferSize(mScrollback); mBinder.getService().setNotification(mNotification); mNotification = null; if (mChatAdapter == null) { mChatAdapter = new ChatMessageAdapter(ChatActivity.this, R.layout.chat_item, mBinder.getService().getChatMsgBuffer()); mListChat.setAdapter(mChatAdapter); } mChatAdapter.notifyDataSetChanged(); setNick(mBinder.getService().getNick()); mDrinkCount = mBinder.getService().getDrinkCount(); updateDrinkCount(); if (!mBinder.getService().isConnected()) { try { // Only connect if we got Username and Password from // MainActivity, otherwise wait until BerryTube reconnect // normally if (mUsername != null && mPassword != null) { NotificationCompat.Builder note = new NotificationCompat.Builder(this); note.setSmallIcon(R.drawable.ic_stat_notify_berrytube); note.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); note.setContentTitle(getString(R.string.title_activity_chat)); Intent intent = new Intent(this, ChatActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.putExtra(MainActivity.KEY_USERNAME, mUsername); intent.putExtra(MainActivity.KEY_PASSWORD, mPassword); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY); note.setContentIntent( PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); mBinder.getService().connect(mUsername, mPassword, note); } } catch (MalformedURLException e) { Log.w(TAG, e); } catch (IllegalStateException e) { // already connected, ignore } } }
From source file:systems.byteswap.publicstream.MainActivity.java
private Notification updateScreenNotification(int command, String parameter) { /** create the notification **/ Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class) .setFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification mNotification;/*from www .j ava 2 s . c o m*/ NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder(mService) .setContentTitle("1 - PublicStream").setSmallIcon(R.drawable.notification_play) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setContentIntent(contentIntent); //PLay Pause PendingIntent piPlayPause = PendingIntent.getBroadcast(mService, 0, new Intent(MediaService.ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT); switch (command) { case NOTIFICATION_COMMAND_CANCEL: mNotificationManager.cancel(MainActivity.NOTIFICATION_PLAY_ID); return null; case NOTIFICATION_COMMAND_UPDATE_ICON: return null; case NOTIFICATION_COMMAND_UPDATE_TEXT: mNotifyBuilder.setContentText(parameter); if (mService.getState().equals(MediaService.MEDIA_STATE_PLAYING)) { mNotifyBuilder.addAction(R.drawable.ic_av_pause_circle_outline, "Pause", piPlayPause); } else { mNotifyBuilder.addAction(R.drawable.ic_av_play_circle_outline, "Play", piPlayPause); } mNotification = mNotifyBuilder.build(); mNotificationManager.notify(MainActivity.NOTIFICATION_PLAY_ID, mNotification); return mNotification; case NOTIFICATION_COMMAND_NOTHING: return mNotifyBuilder.build(); default: return null; } }