Example usage for android.content Intent hasExtra

List of usage examples for android.content Intent hasExtra

Introduction

In this page you can find the example usage for android.content Intent hasExtra.

Prototype

public boolean hasExtra(String name) 

Source Link

Document

Returns true if an extra value is associated with the given name.

Usage

From source file:com.slx.funstream.ui.streams.StreamActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.stream_layout);

    ButterKnife.bind(this);

    if (toolbar != null) {
        setSupportActionBar(toolbar);/* ww w .j a  v a 2 s  .  co m*/
    }
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    fm = getSupportFragmentManager();

    if (savedInstanceState != null) {
        streamerName = savedInstanceState.getString(STREAMER_NAME);
        streamerId = savedInstanceState.getLong(STREAMER_ID, DEFAULT_NON_EXISTING_VALUE);
    } else {
        Intent startIntent = getIntent();
        if (startIntent.hasExtra(STREAMER_ID) && startIntent.hasExtra(STREAMER_NAME)) {
            streamerName = startIntent.getStringExtra(STREAMER_NAME);
            streamerId = startIntent.getLongExtra(STREAMER_ID, DEFAULT_NON_EXISTING_VALUE);
        }
    }

    chatFragment = createChatFragment();

    userStore.userObservable().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new DisposableSubscriber<CurrentUser>() {
                @Override
                public void onNext(CurrentUser currentUser) {
                    Log.d(TAG, "UserStore->fetchUser->onNext " + currentUser);
                    user = currentUser;
                    invalidateOptionsMenu();
                }

                @Override
                public void onError(Throwable t) {
                    t.printStackTrace();
                }

                @Override
                public void onComplete() {
                    Log.d(TAG, "UserStore->fetchUser->onComplete");
                }
            });
}

From source file:be.evias.cloudLogin.cloudLoginMainActivity.java

private void processLogoutServerSide(final Account account) {
    new AsyncTask<String, Void, Intent>() {
        @Override/*from ww w. j  a  v a  2 s . c om*/
        protected Intent doInBackground(String... params) {

            Bundle data = new Bundle();
            try {
                sServerAuthenticate.userSignOut(mContext, account.name);
                data.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);

                Log.d("cloudLogin", "cloudloginMainActivity/logoutAccount: userSignOut successful.");
                showMessage(mContext.getString(R.string.message_logout_success), Toast.LENGTH_SHORT);
            } catch (Exception e) {
                Log.d("cloudLogin", "cloudloginMainActivity/logoutAccount: userSignOut error.");
                e.printStackTrace();
                data.putString(KEY_ERROR_MESSAGE, e.getMessage());
            }

            final Intent res = new Intent();
            res.putExtras(data);
            return res;
        }

        @Override
        protected void onPostExecute(Intent intent) {
            if (intent.hasExtra(KEY_ERROR_MESSAGE))
                Toast.makeText(getBaseContext(), intent.getStringExtra(KEY_ERROR_MESSAGE), Toast.LENGTH_SHORT)
                        .show();
            else
                finishLogout(intent);
        }
    }.execute();
}

From source file:com.nomprenom2.view.NameParamsFragment.java

/**
 * Receives result from select region activity, apply new regions list
 * @param requestCode/*from  w  ww  .  ja va2  s.c o  m*/
 * @param resultCode
 * @param data
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK && requestCode == MainActivity.GROUP_REQUEST) {
        regions.clear();
        if (data.hasExtra(MainActivity.REGIONS)) {
            regions.addAll(data.getStringArrayListExtra(MainActivity.REGIONS));
        }
        setGroupList();
    }
}

From source file:com.app.cat.ui.PhoneBookActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set UI application context
    ApplicationContext.setActivity(this);

    // Mockup telephone book ui data.
    List<CATFriend> catAccounts = new ArrayList<CATFriend>();
    telephoneBookAdapter = new TelephoneBookAdapter(this, catAccounts);
    listTBook.setAdapter(telephoneBookAdapter);

    receiver = new BroadcastReceiver() {
        @Override//from  w w w.j  a v  a2  s. co m
        public void onReceive(Context context, Intent intent) {
            if (intent.hasExtra(ApplicationContext.KEY_SHOW_ERROR_MESSAGE)) {
                statusBarText.setText(intent.getStringExtra(ApplicationContext.KEY_SHOW_ERROR_MESSAGE));
                statusBarLayout.setVisibility(View.VISIBLE);
                listTBook.setVisibility(View.GONE);
            } else if (intent.hasExtra(ApplicationContext.KEY_HIDE_ERROR_MESSAGE)) {
                statusBarText.setText("");
                statusBarLayout.setVisibility(View.GONE);
                listTBook.setVisibility(View.VISIBLE);
            }
        }
    };

    try {
        // ToDo: Check transport choosing in linphone implementation: {@link LinphonePreferenes}
        int udp = 0;
        int tcp = 5060;
        int tls = 0;

        // Get singleton object.
        client = LinphoneCATClient.getInstance();
        client.setTransportType(udp, tcp, tls);

        configuration = PropertiesLoader.loadProperty(this.getAssets().open("config.properties"),
                Arrays.asList("username", "password", "domain", "friendUsername"));

        catUser = new CATUser(configuration.get("username"), configuration.get("password"),
                configuration.get("domain"));

        Log.v("Password_HA1",
                HashGenerator.ha1(catUser.getUsername(), catUser.getDomain(), configuration.get("password")));
        Log.v("Password_HA1B",
                HashGenerator.ha1b(catUser.getUsername(), catUser.getDomain(), configuration.get("password")));

        info.setText("User = " + configuration.get("username"));

        catFriend = new CATFriend(configuration.get("friendUsername"), configuration.get("domain"));
        catAccounts.add(catFriend);

        client.addCATFriend(catFriend);
        client.register(catUser);

        // Starts an service in background
        service = new Intent(PhoneBookActivity.this, CATService.class);
        startService(service);
    } catch (LinphoneCoreException | NoSuchAlgorithmException e) {
        ApplicationContext.showToast(ApplicationContext.getStringFromRessources(R.string.unknown_error_message),
                Toast.LENGTH_SHORT);
        e.printStackTrace();
    } catch (IOException e) {
        info.setText("No mockup data set");
    }
}

From source file:com.yek.keyboard.ui.settings.MainSettingsActivity.java

private void handleAppShortcuts(Intent intent) {
    if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())
            && intent.hasExtra(EXTRA_KEY_APP_SHORTCUT_ID)) {
        final String shortcutId = intent.getStringExtra(EXTRA_KEY_APP_SHORTCUT_ID);
        intent.removeExtra(EXTRA_KEY_APP_SHORTCUT_ID);

        switch (shortcutId) {
        case "keyboards":
            //  onNavigateToKeyboardAddonSettings(null);
            break;
        case "themes":
            // onNavigateToKeyboardThemeSettings(null);
            break;
        case "gestures":
            //  onNavigateToGestureSettings(null);
            break;
        case "quick_keys":
            // onNavigateToQuickTextSettings(null);
            break;
        case "ui_tweaks":
            //onNavigateToUserInterfaceSettings(null);
            break;
        default://from  w  w  w. ja v a 2 s  . c  o  m
            throw new IllegalArgumentException("Unknown app-shortcut " + shortcutId);
        }
    }
}

From source file:com.gm.goldencity.activity.search.SearchActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);/*from  w w w  . ja  va 2 s  .c om*/

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            String query = intent.getStringExtra(SearchManager.QUERY);
            SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                    SuggestionProvider.AUTHORITY, SuggestionProvider.MODE);
            suggestions.saveRecentQuery(query, null);
            if (!TextUtils.isEmpty(query)) {
                searchview.setQuery(query, false);
            }
        }
    }

    initSearchFragment();
}

From source file:com.hybris.mobile.activity.PaymentDetailActivity.java

@SuppressWarnings("unchecked")
private void handleIntent(Intent intent) {
    if (intent.hasExtra("value")) {
        try {/*from  ww  w . j  a  v a2  s  . c o  m*/
            JSONObject payment = new JSONObject(intent.getStringExtra("value"));
            mPaymentID = payment.getString("id");
            for (int i = 0; i < entries.size(); i++) {
                Hashtable<String, Object> dict = (Hashtable<String, Object>) entries.get(i);
                String path = "$." + dict.get("property").toString();
                String value = "";
                try {
                    // We append a String a the end to handle the non String objects
                    value = JsonPath.read(payment.toString(), path) + "";
                } catch (Exception exp) {
                    value = "";
                }

                if (value != null) {
                    dict.put("value", value);
                }

            }
        } catch (JSONException e) {
            LoggingUtils.e(LOG_TAG, "Error parsing Json. " + e.getLocalizedMessage(), Hybris.getAppContext());
        }

    }
}

From source file:com.droid080419.droid080419.elevenfifty_nine.AltAddTaskActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ADD_TASK_REQUEST && resultCode == RESULT_OK) {
        if (data != null && data.hasExtra("LATITUDE") && data.hasExtra("LONGITUDE")) {
            coords = new LatLng(data.getDoubleExtra("LATITUDE", MapsActivity.UPD.latitude),
                    data.getDoubleExtra("LONGITUDE", MapsActivity.UPD.longitude));
            Log.d("MAPS", "EXTRas");
        }//from w w w  . j  a  v a 2 s.  c o m
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.wheelly.fragments.LocationsListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final Intent intent = getActivity().getIntent();
    inSelectMode = intent.hasExtra(LocationActivity.LOCATION_ID_EXTRA);
    getListView().setChoiceMode(inSelectMode ? ListView.CHOICE_MODE_SINGLE : ListView.CHOICE_MODE_NONE);
    setListAdapter(buildAdapter());//from  www.  j av  a2 s . co  m
    ApiAdapterFactory.getApiAdapter().configureListViewContextualMenu(this, contextualActionModeCallback);
    setHasOptionsMenu(true);
    BusProvider.getInstance().register(this);
}

From source file:com.adnanbal.fxdedektifi.forex.presentation.services.NotificationService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null && intent.hasExtra("counter")) {
        Bundle bundle = intent.getExtras();
        countFlag = bundle.getInt("counter");
    } else {/*  w ww.ja  va2 s. c  om*/
        countFlag = 0;
    }

    Firebase.setAndroidContext(getApplicationContext());

    Firebase myFirebaseRef = new Firebase("https://fxingsign.firebaseio.com/");

    if (isThereInternetConnection()) {

        myFirebaseRef.child("signal").addChildEventListener(new ChildEventListener() {

            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {

                if (countFlag > 0) {
                    SignalModel signalModel;

                    signalModel = dataSnapshot.getValue(SignalModel.class);
                    signalModel.setId(dataSnapshot.getKey());
                    //TODO : Notification impl. code

                    if (!AndroidApplication.listChangedSignalModel.contains(signalModel)) {
                        AndroidApplication.listChangedSignalModel.add(signalModel);
                    }

                    showUpdatedSignalNotification(signalModel, "Open");

                } else {
                    //DataInitialization
                }

            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {

                SignalModel signalModel;

                signalModel = dataSnapshot.getValue(SignalModel.class);
                signalModel.setId(dataSnapshot.getKey());

                if (!AndroidApplication.listChangedSignalModel.contains(signalModel)) {
                    AndroidApplication.listChangedSignalModel.add(signalModel);
                }

                //TODO : Notification impl. code
                if (signalModel.getClosingPrice() != 0) {
                    showUpdatedSignalNotification(signalModel, "Closed");
                } else {
                    showUpdatedSignalNotification(signalModel, "Updated");
                }

            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
                SignalModel signalModel;

                signalModel = dataSnapshot.getValue(SignalModel.class);
                signalModel.setId(dataSnapshot.getKey());
                //TODO : Notification for signal closing

                showUpdatedSignalNotification(signalModel, "Closed");

            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {

            }

            @Override
            public void onCancelled(FirebaseError firebaseError) {
                Log.e(TAG, new FirebaseException(firebaseError.getMessage()).getMessage());

            }
        });

        myFirebaseRef.child("signal").addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                countFlag++;
            }

            @Override
            public void onCancelled(FirebaseError firebaseError) {

            }
        });

    } else {
        //      Log.e(TAG, new NetworkConnectionException().getMessage());
    }
    return START_STICKY;
}