List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:br.com.moviecreator.views.home.HomeFragment.java
@Nullable @Override/*from www .j a va 2s .c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.home_app_bar, container, false); adapter = new MoviesAdapter(new ArrayList<Movie>(), LayoutInflater.from(getActivity()), new ItemClickListener<Movie>() { @Override public void onItemClick(Movie movie) { Bundle extra = new Bundle(); extra.putSerializable(DetailsActivity.DETAILS_EXTRA, movie); Intent intent = new Intent(getActivity(), DetailsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtras(extra); getActivity().startActivity(intent); } }); gridLayoutManager = new GridLayoutManager(getActivity(), 2); gridLayoutManager.setOrientation(GridLayoutManager.VERTICAL); boryLayout = (LinearLayout) rootView.findViewById(R.id.home_bory_search); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh); swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimary, R.color.colorPrimaryDark); swipeRefreshLayout.setEnabled(false); RecyclerView recyclerViewMovies = (RecyclerView) rootView.findViewById(R.id.movies_result_list); recyclerViewMovies.setHasFixedSize(true); recyclerViewMovies.setLayoutManager(gridLayoutManager); recyclerViewMovies.setAdapter(adapter); recyclerViewMovies.addItemDecoration(new SpacesItemDecoration(10)); boryLayout.setVisibility(View.VISIBLE); swipeRefreshLayout.setVisibility(View.GONE); return rootView; }
From source file:com.android.dialer.settings.DialerSettingsActivity.java
@Override public void onBuildHeaders(List<Header> target) { Header displayOptionsHeader = new Header(); displayOptionsHeader.titleRes = R.string.display_options_title; displayOptionsHeader.fragment = DisplayOptionsSettingsFragment.class.getName(); target.add(displayOptionsHeader);/* w ww . j a v a 2 s . co m*/ Header soundSettingsHeader = new Header(); soundSettingsHeader.titleRes = R.string.sounds_and_vibration_title; soundSettingsHeader.fragment = SoundSettingsFragment.class.getName(); soundSettingsHeader.id = R.id.settings_header_sounds_and_vibration; target.add(soundSettingsHeader); if (CompatUtils.isMarshmallowCompatible()) { Header quickResponseSettingsHeader = new Header(); Intent quickResponseSettingsIntent = new Intent(TelecomManager.ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS); quickResponseSettingsHeader.titleRes = R.string.respond_via_sms_setting_title; quickResponseSettingsHeader.intent = quickResponseSettingsIntent; target.add(quickResponseSettingsHeader); } TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); // "Call Settings" (full settings) is shown if the current user is primary user and there // is only one SIM. Before N, "Calling accounts" setting is shown if the current user is // primary user and there are multiple SIMs. In N+, "Calling accounts" is shown whenever // "Call Settings" is not shown. boolean isPrimaryUser = isPrimaryUser(); if (isPrimaryUser && TelephonyManagerCompat.getPhoneCount(telephonyManager) <= 1) { Header callSettingsHeader = new Header(); Intent callSettingsIntent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS); callSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); callSettingsHeader.titleRes = R.string.call_settings_label; callSettingsHeader.intent = callSettingsIntent; target.add(callSettingsHeader); } else if (BuildCompat.isAtLeastN() || isPrimaryUser) { Header phoneAccountSettingsHeader = new Header(); Intent phoneAccountSettingsIntent = new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS); phoneAccountSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); phoneAccountSettingsHeader.titleRes = R.string.phone_account_settings_label; phoneAccountSettingsHeader.intent = phoneAccountSettingsIntent; target.add(phoneAccountSettingsHeader); } if (FilteredNumberCompat.canCurrentUserOpenBlockSettings(this)) { Header blockedCallsHeader = new Header(); blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label; blockedCallsHeader.intent = FilteredNumberCompat.createManageBlockedNumbersIntent(this); target.add(blockedCallsHeader); migrationStatusOnBuildHeaders = FilteredNumberCompat.hasMigratedToNewBlocking(); } if (isPrimaryUser && (TelephonyManagerCompat.isTtyModeSupported(telephonyManager) || TelephonyManagerCompat.isHearingAidCompatibilitySupported(telephonyManager))) { Header accessibilitySettingsHeader = new Header(); Intent accessibilitySettingsIntent = new Intent(TelecomManager.ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS); accessibilitySettingsHeader.titleRes = R.string.accessibility_settings_title; accessibilitySettingsHeader.intent = accessibilitySettingsIntent; target.add(accessibilitySettingsHeader); } }
From source file:de.micmun.android.workdaystarget.DaysLeftService.java
/** * Updates the days to target./*from www .j a v a 2s .co m*/ */ private void updateDays() { AppWidgetManager appManager = AppWidgetManager.getInstance(this); ComponentName cName = new ComponentName(getApplicationContext(), DaysLeftProvider.class); int[] appIds = appManager.getAppWidgetIds(cName); DayCalculator dayCalc = new DayCalculator(); if (!isOnline()) { try { Thread.sleep(60000); } catch (InterruptedException e) { Log.e(TAG, "Interrupted: " + e.getLocalizedMessage()); } } for (int appId : appIds) { PrefManager pm = new PrefManager(this, appId); Calendar target = pm.getTarget(); boolean[] chkDays = pm.getCheckedDays(); int days = pm.getLastDiff(); if (isOnline()) { try { days = dayCalc.getDaysLeft(target.getTime(), chkDays); Map<String, Object> saveMap = new HashMap<String, Object>(); Long diff = Long.valueOf(days); saveMap.put(PrefManager.KEY_DIFF, diff); pm.save(saveMap); } catch (JSONException e) { Log.e(TAG, "ERROR holidays: " + e.getLocalizedMessage()); } } else { Log.e(TAG, "No internet connection!"); } RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.appwidget_layout); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); String targetStr = df.format(target.getTime()); rv.setTextViewText(R.id.target, targetStr); String dayStr = String.format(Locale.getDefault(), "%d %s", days, getResources().getString(R.string.unit)); rv.setTextViewText(R.id.dayCount, dayStr); // put widget id into intent Intent configIntent = new Intent(this, ConfigActivity.class); configIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId); configIntent.setData(Uri.parse(configIntent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setOnClickPendingIntent(R.id.widgetLayout, pendIntent); // update widget appManager.updateAppWidget(appId, rv); } }
From source file:com.fabernovel.alertevoirie.MyIncidentsActivityMap.java
/** Called when the activity is first created. */ @Override/*from w ww. ja va 2s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.layout_report_map); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon_mes_rapports); map = (MapView) findViewById(R.id.MapView_mymap); map.setBuiltInZoomControls(true); tabs = (RadioGroup) findViewById(R.id.RadioGroup_tabs_map); // mOverlay = new SimpleItemizedOverlay(getResources().getDrawable(R.drawable.map_cursor), this, map); map.getOverlays().add(mOverlay); map.setSatellite(false); tbmap = (ToggleButton) findViewById(R.id.ToggleButton_Map); tbmap.setChecked(true); tbmap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { tbmap.setChecked(true); Intent i = new Intent(MyIncidentsActivityMap.this, MyIncidentsActivity.class); i.putExtra("tab1", title[0]); i.putExtra("tab2", title[1]); i.putExtra("tab3", title[2]); i.putExtra("datas", data.toString()); i.putExtra("tab", checked); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(i); } } }); if (getIntent().getExtras().getInt("tab") != 0) { title[0] = getIntent().getExtras().getString("tab1"); title[1] = getIntent().getExtras().getString("tab2"); title[2] = getIntent().getExtras().getString("tab3"); ((TextView) tabs.getChildAt(0)).setText(title[0]); if (title[0].startsWith("0")) ((TextView) tabs.getChildAt(0)).setEnabled(false); ((TextView) tabs.getChildAt(1)).setText(title[1]); if (title[1].startsWith("0")) ((TextView) tabs.getChildAt(1)).setEnabled(false); ((TextView) tabs.getChildAt(2)).setText(title[2]); if (title[2].startsWith("0")) ((TextView) tabs.getChildAt(2)).setEnabled(false); checked = getIntent().getExtras().getInt("tab"); try { data = new JSONObject(getIntent().getExtras().getString("datas")); } catch (JSONException e) { Log.e(Constants.PROJECT_TAG, "JSon data exception", e); } // setMapForTab(gettabIndex(tabs.getCheckedRadioButtonId())); } else { // launch request try { AVService.getInstance(this) .postJSON(new JSONArray().put(new JSONObject() .put(JsonData.PARAM_REQUEST, JsonData.VALUE_REQUEST_GET_MY_INCIDENTS) .put(JsonData.PARAM_UDID, Utils.getUdid(this))), this); showDialog(DIALOG_PROGRESS); } catch (JSONException e) { Log.e(Constants.PROJECT_TAG, "error launching My Incidents", e); } } // get view references tabs.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { Log.d(Constants.PROJECT_TAG, "checked : " + checkedId); checked = checkedId; setMapForTab(gettabIndex(checkedId)); } }); tabs.check(getId()); if (checked == R.id.Tab_Map_ongoing) { setMapForTab(gettabIndex(checked)); } }
From source file:net.frygo.findmybuddy.GCMIntentService.java
private static void generateNotification(Context context, String message) { Random rand = new Random(); int x = rand.nextInt(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, customlistview.class); notificationIntent.putExtra("alert", message); message = message + " would like to add you as friend"; PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new Notification(R.drawable.logo, message, System.currentTimeMillis()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(x, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock mWakelock = pm .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, title); mWakelock.acquire();// ww w . j av a 2 s .c o m // Timer before putting Android Device to sleep mode. Timer timer = new Timer(); TimerTask task = new TimerTask() { public void run() { mWakelock.release(); } }; timer.schedule(task, 5000); }
From source file:com.codebutler.farebot.activities.AddKeyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_key); getWindow().setLayout(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT); findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { @Override/* w w w . j a va2 s .c o m*/ public void onClick(View view) { setResult(RESULT_CANCELED); finish(); } }); findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final String keyType = ((RadioButton) findViewById(R.id.is_key_a)).isChecked() ? ClassicSectorKey.TYPE_KEYA : ClassicSectorKey.TYPE_KEYB; new BetterAsyncTask<Void>(AddKeyActivity.this, true, false) { @Override protected Void doInBackground() throws Exception { ClassicCardKeys keys = ClassicCardKeys.fromDump(keyType, mKeyData); ContentValues values = new ContentValues(); values.put(KeysTableColumns.CARD_ID, mTagId); values.put(KeysTableColumns.CARD_TYPE, mCardType); values.put(KeysTableColumns.KEY_DATA, keys.toJSON().toString()); getContentResolver().insert(CardKeyProvider.CONTENT_URI, values); return null; } @Override protected void onResult(Void unused) { Intent intent = new Intent(AddKeyActivity.this, KeysActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } }.execute(); } }); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); Utils.checkNfcEnabled(this, mNfcAdapter); Intent intent = getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); mPendingIntent = PendingIntent.getActivity(this, 0, intent, 0); if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_VIEW) && getIntent().getData() != null) { try { InputStream stream = getContentResolver().openInputStream(getIntent().getData()); mKeyData = IOUtils.toByteArray(stream); } catch (IOException e) { Utils.showErrorAndFinish(this, e); } } else { finish(); } }
From source file:com.baochu.androidassignment.notification.GcmIntentService.java
/** Issues a notification to inform the user */ private void sendNotification(String msg) { int msgId = Utils.getMessageId(); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(this, MainActivity.class); // set intent so it does not start a new activity intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(GcmActivity.EXTRA_MESSAGE, msg); PendingIntent contentIntent = PendingIntent.getActivity(this, msgId, intent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(this.getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg) .setDefaults(Notification.DEFAULT_SOUND).setAutoCancel(true); builder.setContentIntent(contentIntent); mNotificationManager.notify(msgId, builder.build()); }
From source file:at.ac.tuwien.caa.docscan.ui.StartActivity.java
private void startCamera() { Intent intent = new Intent(this, CameraActivity.class); intent.setFlags(/* w ww .ja v a 2 s . c om*/ Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); }
From source file:com.andreadec.musicplayer.MusicService.java
/** * Called when the service is created./*ww w.j a v a 2s . com*/ */ @Override public void onCreate() { PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MusicServiceWakelock"); // Initialize the telephony manager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); phoneStateListener = new MusicPhoneStateListener(); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // Initialize pending intents quitPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.andreadec.musicplayer.quit"), 0); previousPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.andreadec.musicplayer.previous"), 0); playpausePendingIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.andreadec.musicplayer.playpause"), 0); nextPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.andreadec.musicplayer.next"), 0); pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP), PendingIntent.FLAG_UPDATE_CURRENT); // Read saved user preferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // Initialize the media player mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setWakeMode(this, PowerManager.PARTIAL_WAKE_LOCK); // Enable the wake lock to keep CPU running when the screen is switched off shuffle = preferences.getBoolean(Constants.PREFERENCE_SHUFFLE, Constants.DEFAULT_SHUFFLE); repeat = preferences.getBoolean(Constants.PREFERENCE_REPEAT, Constants.DEFAULT_REPEAT); repeatAll = preferences.getBoolean(Constants.PREFERENCE_REPEATALL, Constants.DEFAULT_REPEATALL); try { // This may fail if the device doesn't support bass boost bassBoost = new BassBoost(1, mediaPlayer.getAudioSessionId()); bassBoost.setEnabled( preferences.getBoolean(Constants.PREFERENCE_BASSBOOST, Constants.DEFAULT_BASSBOOST)); setBassBoostStrength(preferences.getInt(Constants.PREFERENCE_BASSBOOSTSTRENGTH, Constants.DEFAULT_BASSBOOSTSTRENGTH)); bassBoostAvailable = true; } catch (Exception e) { bassBoostAvailable = false; } try { // This may fail if the device doesn't support equalizer equalizer = new Equalizer(1, mediaPlayer.getAudioSessionId()); equalizer.setEnabled( preferences.getBoolean(Constants.PREFERENCE_EQUALIZER, Constants.DEFAULT_EQUALIZER)); setEqualizerPreset( preferences.getInt(Constants.PREFERENCE_EQUALIZERPRESET, Constants.DEFAULT_EQUALIZERPRESET)); equalizerAvailable = true; } catch (Exception e) { equalizerAvailable = false; } random = new Random(System.nanoTime()); // Necessary for song shuffle shakeListener = new ShakeListener(this); if (preferences.getBoolean(Constants.PREFERENCE_SHAKEENABLED, Constants.DEFAULT_SHAKEENABLED)) { shakeListener.enable(); } telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); // Start listen for telephony events // Inizialize the audio manager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mediaButtonReceiverComponent = new ComponentName(getPackageName(), MediaButtonReceiver.class.getName()); audioManager.registerMediaButtonEventReceiver(mediaButtonReceiverComponent); audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); // Initialize remote control client if (Build.VERSION.SDK_INT >= 14) { icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mediaButtonReceiverComponent); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); audioManager.registerRemoteControlClient(remoteControlClient); } updateNotificationMessage(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.andreadec.musicplayer.quit"); intentFilter.addAction("com.andreadec.musicplayer.previous"); intentFilter.addAction("com.andreadec.musicplayer.previousNoRestart"); intentFilter.addAction("com.andreadec.musicplayer.playpause"); intentFilter.addAction("com.andreadec.musicplayer.next"); intentFilter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY); broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals("com.andreadec.musicplayer.quit")) { sendBroadcast(new Intent("com.andreadec.musicplayer.quitactivity")); stopSelf(); return; } else if (action.equals("com.andreadec.musicplayer.previous")) { previousItem(false); } else if (action.equals("com.andreadec.musicplayer.previousNoRestart")) { previousItem(true); } else if (action.equals("com.andreadec.musicplayer.playpause")) { playPause(); } else if (action.equals("com.andreadec.musicplayer.next")) { nextItem(); } else if (action.equals(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) { if (preferences.getBoolean(Constants.PREFERENCE_STOPPLAYINGWHENHEADSETDISCONNECTED, Constants.DEFAULT_STOPPLAYINGWHENHEADSETDISCONNECTED)) { pause(); } } } }; registerReceiver(broadcastReceiver, intentFilter); if (!isPlaying()) { loadLastSong(); } startForeground(Constants.NOTIFICATION_MAIN, notification); }
From source file:com.example.pyrkesa.shwc.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_log);//from www . j a v a2 s. c om final ModelFactory model = (ModelFactory) ModelFactory.getContext(); UserAuthenticate = model.UserAuthenticate; //For settings option-- put it in the first acticity on the onCreate function if (getIntent().getBooleanExtra("Exit me", false)) { finish(); } if (LoginActivity.UserAuthenticate) { Intent homepage = new Intent(getApplicationContext(), MainActivity.class); homepage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(homepage); finish(); } final Handler searchipHandler = new Handler() { @Override public void handleMessage(Message msg) { String shwcipadress = msg.getData().getString("ip"); if (shwcipadress != null) { if (LoginActivity.UserAuthenticate == false) { LoginActivity.shwcserverFound = true; LoginActivity.url_all_box = "http://" + shwcipadress + "/SHWCDataManagement/Box/get_all_box.php"; LoginActivity.url_authenticate = "http://" + shwcipadress + "/SHWCDataManagement/Users/authenticate.php"; LoginActivity.url_authenticateByDevice = "http://" + shwcipadress + "/SHWCDataManagement/Users/authenticateByDevice.php"; Log.d("SHWCServer", "IP=" + shwcipadress); String android_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.d("Android id :", android_id); ArrayList<String> Logs1 = new ArrayList<String>(); Logs1.add(url_authenticateByDevice); Logs1.add(android_id); Logs1.add(url_all_box); new AuthenticateUserByDevice().execute(Logs1); } } } }; // Run the ServiceNSD to find the shwcserver //final FindServicesNSD zeroconf=new FindServicesNSD((NsdManager)getSystemService(NSD_SERVICE), "_http._tcp",searchipHandler); //zeroconf.run(); // LoginActivity.x=zeroconf; // simulation dcouverte serveur shwc LoginActivity.shwcserverFound = true; model.api_url = "http://" + "10.0.1.5" + "/SHWCDataManagement/"; LoginActivity.url_all_box = model.api_url + "Box/get_all_box.php"; LoginActivity.url_authenticate = model.api_url + "Users/authenticate.php"; LoginActivity.url_authenticateByDevice = model.api_url + "Users/authenticateByDevice.php"; String android_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.d("Android id :", android_id); ArrayList<String> Logs1 = new ArrayList<String>(); Logs1.add(url_authenticateByDevice); Logs1.add(android_id); Logs1.add(url_all_box); if (getIntent().hasExtra("logout")) { new LoadAllBoxes().execute(url_all_box); } else { new AuthenticateUserByDevice().execute(Logs1); } /// end simulation LogInButton = ((ImageButton) this.findViewById(R.id.LogInButton)); // Get login and password from EditText final EditText login = ((EditText) this.findViewById(R.id.login)); final EditText password = ((EditText) this.findViewById(R.id.password)); final Spinner box_choice = ((Spinner) this.findViewById(R.id.box_choice)); LogInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (LoginActivity.shwcserverFound) { String pass = password.getText().toString(); String log = login.getText().toString(); String box = box_choice.getSelectedItem().toString(); String android_id1 = Secure.getString(getContentResolver(), Secure.ANDROID_ID); ArrayList<String> Logs = new ArrayList<String>(); Logs.add(log); Logs.add(pass); Logs.add(url_authenticate); Logs.add(android_id1); Logs.add(box); new AuthenticateUser().execute(Logs); } else { Toast.makeText(LoginActivity.this, "Systme SHWC indisponible !", Toast.LENGTH_LONG).show(); } } }); // on seleting single product // launching Edit Product Screen }