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.shafiq.myfeedle.core.PhotoUploadService.java

private void start(Intent intent) {
    if (intent != null) {
        String action = intent.getAction();
        if (Myfeedle.ACTION_UPLOAD.equals(action)) {
            if (intent.hasExtra(Accounts.TOKEN) && intent.hasExtra(Statuses.MESSAGE)
                    && intent.hasExtra(Widgets.INSTANT_UPLOAD)) {
                String place = null;
                if (intent.hasExtra(Splace))
                    place = intent.getStringExtra(Splace);
                String tags = null;
                if (intent.hasExtra(Stags))
                    tags = intent.getStringExtra(Stags);
                // upload a photo
                Notification notification = new Notification(R.drawable.notification, "uploading photo",
                        System.currentTimeMillis());
                notification.setLatestEventInfo(getBaseContext(), "photo upload", "uploading",
                        PendingIntent.getActivity(PhotoUploadService.this, 0,
                                (Myfeedle.getPackageIntent(PhotoUploadService.this, About.class)), 0));
                ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID,
                        notification);/*from w w w. j  av  a2s .c om*/
                (new AsyncTask<String, Void, String>() {

                    @Override
                    protected String doInBackground(String... params) {
                        String response = null;
                        if (params.length > 2) {
                            Log.d(TAG, "upload file: " + params[2]);
                            HttpPost httpPost = new HttpPost(String.format(FACEBOOK_PHOTOS, FACEBOOK_BASE_URL,
                                    Saccess_token, mMyfeedleCrypto.Decrypt(params[0])));
                            MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
                            File file = new File(params[2]);
                            ContentBody fileBody = new FileBody(file);
                            entity.addPart(Ssource, fileBody);
                            HttpClient httpClient = MyfeedleHttpClient
                                    .getThreadSafeClient(getApplicationContext());
                            try {
                                entity.addPart(Smessage, new StringBody(params[1]));
                                if (params[3] != null)
                                    entity.addPart(Splace, new StringBody(params[3]));
                                if (params[4] != null)
                                    entity.addPart(Stags, new StringBody(params[4]));
                                httpPost.setEntity(entity);
                                response = MyfeedleHttpClient.httpResponse(httpClient, httpPost);
                            } catch (UnsupportedEncodingException e) {
                                Log.e(TAG, e.toString());
                            }
                        }
                        return response;
                    }

                    @Override
                    protected void onPostExecute(String response) {
                        // notify photo success
                        String message = getString(response != null ? R.string.success : R.string.failure);
                        Notification notification = new Notification(R.drawable.notification,
                                "photo upload " + message, System.currentTimeMillis());
                        notification.setLatestEventInfo(getBaseContext(), "photo upload", message,
                                PendingIntent.getActivity(PhotoUploadService.this, 0,
                                        (Myfeedle.getPackageIntent(PhotoUploadService.this, About.class)), 0));
                        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID,
                                notification);
                        stopSelfResult(mStartId);
                    }

                }).execute(intent.getStringExtra(Accounts.TOKEN), intent.getStringExtra(Statuses.MESSAGE),
                        intent.getStringExtra(Widgets.INSTANT_UPLOAD), place, tags);
            }
        }
    }
}

From source file:com.shafiq.myfeedle.core.SelectFriends.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // allow posting to multiple services if an account is defined
    // allow selecting which accounts to use
    // get existing comments, allow liking|unliking those comments
    setContentView(R.layout.friends);/*w w w  . ja  v a  2  s  .c o m*/
    if (!getPackageName().toLowerCase().contains(PRO)) {
        AdView adView = new AdView(this, AdSize.BANNER, MyfeedleTokens.GOOGLE_AD_ID);
        ((LinearLayout) findViewById(R.id.ad)).addView(adView);
        adView.loadAd(new AdRequest());
    }
    Intent intent = getIntent();
    if ((intent != null) && intent.hasExtra(Accounts.SID)) {
        mAccountId = intent.getLongExtra(Accounts.SID, Myfeedle.INVALID_ACCOUNT_ID);
        String[] tags = intent.getStringArrayExtra(Stags);
        if (tags != null) {
            for (String tag : tags)
                mSelectedFriends.add(tag);
        }
    } else
        finish();

    mHttpClient = MyfeedleHttpClient.getThreadSafeClient(getApplicationContext());
    registerForContextMenu(getListView());
    setResult(RESULT_CANCELED);
}

From source file:com.playcez.GooglePlus.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    if (intent == null || !intent.hasExtra("token")) {
        AuthUtils.refreshAuthToken(this);
        return;//  w w w  .j  a va  2s. c  o  m
    }

    setContentView(R.layout.activity_list);
    mListView = (ListView) findViewById(R.id.activityList);

    loginProgress = ProgressDialog.show(GooglePlus.this, "Please wait", "Autheticating...", true);

    AsyncTask<String, Void, List<Activity>> task = new AsyncTask<String, Void, List<Activity>>() {

        @Override
        protected List<Activity> doInBackground(String... params) {
            try {
                plus = new PlusWrap(GooglePlus.this).get();
                Person mePerson = plus.people().get("me").execute();

                Log.d(TAG, "ID:\t" + mePerson.getId());
                Log.d(TAG, "Display Name:\t" + mePerson.getDisplayName());
                Log.d(TAG, "Image URL:\t" + mePerson.getImage().getUrl());
                Log.d(TAG, "Profile URL:\t" + mePerson.getUrl());

                final String TOKEN = "access_token";
                SharedPreferences myData = getSharedPreferences("myData", MODE_PRIVATE);
                Editor edit = myData.edit();
                edit.putString(TOKEN, "access_token");
                edit.putString("uid", mePerson.getId());
                edit.commit();
                Log.d(TAG, "hererre");
                String placesLived = "";
                String name = "";
                String json = "";
                JSONArray obj = null;
                try {
                    name = mePerson.getDisplayName().toString();
                    placesLived = mePerson.getPlacesLived().toString();
                    List<PersonPlacesLived> object = mePerson.getPlacesLived();
                    json = object.toString();
                    obj = new JSONArray(json);
                    json = obj.toString();
                } catch (Exception e) {
                    e.printStackTrace();
                }

                final SharedPreferences settings = getSharedPreferences(AuthUtils.PREFS_NAME, 0);
                final String account_name = settings.getString(AuthUtils.PREF_ACCOUNT_NAME, "");
                final String accessToken = settings.getString("accessToken", null);

                sendToServer("https://playcez.com/api_getUID.php", name, mePerson.getBirthday(),
                        mePerson.getId(), mePerson.getCurrentLocation(), obj, mePerson.getGender(), accessToken,
                        account_name);

                return plus.activities().list("me", "public").execute().getItems();
            } catch (IOException e) {
                loginProgress.dismiss();
                Toast.makeText(getApplicationContext(), "Check your network connection!", Toast.LENGTH_LONG)
                        .show();
                Log.e(TAG, "Unable to list recommended people for user: " + params[0], e);
            }
            return null;
        }

        @Override
        protected void onPostExecute(List<Activity> feed) {
            if (feed != null) {
                Log.d(TAG, feed + "");
                SharedPreferences data = getSharedPreferences("myData", MODE_PRIVATE);
                boolean showTut = data.getBoolean("showTut", true);
                Editor myEdit = data.edit();
                myEdit.putBoolean("showTut", false);
                myEdit.commit();

                if (showTut) {
                    startActivity(new Intent(getApplicationContext(), Tutorial3.class));
                } else {
                    startActivity(new Intent(getApplicationContext(), Start_Menu.class));
                }
                finish();
            } else {
            }
        }
    };
    task.execute("me");
}

From source file:my.home.lehome.service.SendMsgIntentService.java

private void preparePengindCommand(Intent intent) {
    Messenger messenger;/*from   ww  w.j av  a  2 s  .  c  o  m*/
    if (intent.hasExtra("messenger"))
        messenger = (Messenger) intent.getExtras().get("messenger");
    else
        messenger = null;
    Message repMsg = Message.obtain();
    repMsg.what = MSG_BEGIN_SENDING;

    boolean isSysCmd = intent.getBooleanExtra("isSysCmd", false);
    if (isSysCmd) {
        Log.d(TAG, "sys cmd item");
        return;
    }

    ChatItem item = intent.getParcelableExtra("update");
    if (item == null) {
        item = new ChatItem();
        item.setContent(intent.getStringExtra("cmd"));
        item.setType(ChatItemConstants.TYPE_CLIENT);
        item.setState(Constants.CHATITEM_STATE_ERROR); // set ERROR
        item.setDate(new Date());
        DBStaticManager.addChatItem(getApplicationContext(), item);
    }
    item.setState(Constants.CHATITEM_STATE_PENDING);

    Log.d(TAG, "enqueue item: \n" + item);
    Bundle bundle = new Bundle();
    bundle.putBoolean("update", intent.hasExtra("update"));
    bundle.putParcelable("item", item);
    if (messenger != null) {
        repMsg.setData(bundle);
        try {
            messenger.send(repMsg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_BEGIN);
        Intent newIntent = new Intent(ACTION_SEND_MSG_BEGIN);
        newIntent.putExtras(bundle);
        sendBroadcast(newIntent);
    }

    intent.putExtra("pass_item", item);
}

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

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RC_LOGIN) {
        if (resultCode == RESULT_OK) {
            if (data.hasExtra(LoginFragment.FIELD_TOKEN) && data.hasExtra(LoginFragment.FIELD_USERID)) {
                CurrentUser user = new CurrentUser();
                Long userId = data.getLongExtra(LoginFragment.FIELD_USERID, DEFAULT_NON_EXISTING_VALUE);
                // Check if something went wrong
                if (userId == DEFAULT_NON_EXISTING_VALUE) {
                    Toaster.makeLongToast(this, getString(R.string.error_login));
                    return;
                }//ww w  .  j  av a2s  . c  o  m
                user.setId(userId);
                user.setName(data.getStringExtra(LoginFragment.FIELD_USERNAME));
                user.setToken(data.getStringExtra(LoginFragment.FIELD_TOKEN));
                prefUtils.saveUser(user);
                userStore.fetchUser();
                invalidateOptionsMenu();
            }
        }
    }
}

From source file:com.linroid.pushapp.ui.home.HomeActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        if (data != null && data.hasExtra(EXTRA_MESSAGE)) {
            Snackbar.make(pager, data.getStringExtra(EXTRA_MESSAGE), Snackbar.LENGTH_SHORT).show();
        }/*from   w w  w  . j av a 2 s.  c  o  m*/
    }
}

From source file:com.aqtx.app.main.activity.MainActivity.java

private void onParseIntent() {
    Intent intent = getIntent();
    if (intent.hasExtra(NimIntent.EXTRA_NOTIFY_CONTENT)) {
        IMMessage message = (IMMessage) getIntent().getSerializableExtra(NimIntent.EXTRA_NOTIFY_CONTENT);
        switch (message.getSessionType()) {
        case P2P:
            SessionHelper.startP2PSession(this, message.getSessionId());
            break;
        case Team:
            SessionHelper.startTeamSession(this, message.getSessionId());
            break;
        default:/*from w  w  w  .j ava2  s .c  o  m*/
            break;
        }
    } else if (intent.hasExtra(EXTRA_APP_QUIT)) {
        onLogout();
        return;
    } else if (intent.hasExtra(AVChatActivity.INTENT_ACTION_AVCHAT)) {
        if (AVChatProfile.getInstance().isAVChatting()) {
            Intent localIntent = new Intent();
            localIntent.setClass(this, AVChatActivity.class);
            startActivity(localIntent);
        }
    } else if (intent.hasExtra(Extras.EXTRA_JUMP_P2P)) {
        Intent data = intent.getParcelableExtra(Extras.EXTRA_DATA);
        String account = data.getStringExtra(Extras.EXTRA_ACCOUNT);
        if (!TextUtils.isEmpty(account)) {
            SessionHelper.startP2PSession(this, account);
        }
    }
}

From source file:com.stfalcon.hromadskyipatrol.services.VideoProcessingService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.d(TAG, "onHandleIntent: start process video service");

    DatabasePatrol db = DatabasePatrol.get(this);

    // add new video to db if need
    if (intent.hasExtra(VideoCaptureActivity.MOVIES_TO_SAVE)) {
        addVideo(intent);/*w ww. java  2 s. c o m*/
    }

    //delete video
    else if (intent.hasExtra(DELETE_MOVIE)) {
        deleteVideo(intent);
    }

    //process all videos
    else {
        ArrayList<VideoItem> videoItems = db.getVideos(VideoItem.State.SAVING,
                ProjectPreferencesManager.getUser(this));

        if (!videoItems.isEmpty()) {
            for (VideoItem item : videoItems) {
                tryToProcessVideo(item, db);
            }
        }
    }

    // start auto upload service if need
    if (ProjectPreferencesManager.getAutoUploadMode(getApplicationContext())) {
        startService(new Intent(VideoProcessingService.this, UploadService.class));
    }
}

From source file:com.android.inputmethod.latin.settings.SettingsActivity.java

@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    final Intent intent = getIntent();
    if (actionBar != null) {
        mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
        actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
        actionBar.setHomeButtonEnabled(mShowHomeAsUp);
    }/*from  ww w . j  ava 2s .  c o m*/
    StatsUtils.onSettingsActivity(intent.hasExtra(EXTRA_ENTRY_KEY) ? intent.getStringExtra(EXTRA_ENTRY_KEY)
            : EXTRA_ENTRY_VALUE_SYSTEM_SETTINGS);
}

From source file:com.ninetwozero.battlelog.ForumActivity.java

public void openFromIntent(Intent intent) {

    // Do we have a saved thread?
    if (intent.hasExtra("savedThread") && savedThread == null) {

        savedThread = intent.getParcelableExtra("savedThread");
        openForum(new Intent().putExtra("forumTitle", "N/A").putExtra("forumId", savedThread.getForumId()));
        openThread(new Intent().putExtra("threadTitle", savedThread.getTitle())
                .putExtra("threadId", savedThread.getId())
                .putExtra("pageId", savedThread.getNumPageLastRead()));

    }/*from   w ww  .  j  a  v  a  2  s .  c  om*/

}