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:de.stadtrallye.rallyesoft.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Log.i(THIS, "Receiving Intent");

    if (intent != null && intent.hasExtra(Std.TAB)) {
        Log.i(THIS, "Receiving Intent with Tab");
        if (intent.getStringExtra(Std.TAB).equals(Std.CHATROOM)) {
            int chatroom = intent.getIntExtra(Std.CHATROOM, -1);
            int chatID = intent.getIntExtra(Std.CHAT_ID, -1);
            Bundle b = new Bundle();
            b.putInt(Std.CHATROOM, chatroom);
            b.putInt(Std.CHAT_ID, chatID);
            tabManager.setArguments(RallyeTabManager.TAB_CHAT, b);
            tabManager.switchToTab(RallyeTabManager.TAB_CHAT);
        }/*from ww  w.j a  v a  2 s .  c om*/
    }
}

From source file:com.granita.tasks.EditTaskActivity.java

@TargetApi(11)
@Override//from  w ww. j  a  va2s .  co m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_task_editor);

    mAuthority = getString(R.string.org_dmfs_tasks_authority);

    //custom start
    Tracker t = ((com.granita.tasks.Tasks) getApplication())
            .getTracker(com.granita.tasks.Tasks.TrackerName.APP_TRACKER);
    t.setScreenName("Tasks: Edit task activity");
    t.send(new HitBuilders.AppViewBuilder().build());
    //custom end

    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // hide up button in action bar
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.content_remove_light);
        // actionBar.setDisplayShowTitleEnabled(false);
    }

    if (savedInstanceState == null) {

        Bundle arguments = new Bundle();
        Intent intent = getIntent();
        String action = intent.getAction();

        setActivityTitle(action);

        if (Intent.ACTION_SEND.equals(action)) {

            // load data from incoming share intent
            ContentSet sharedContentSet = new ContentSet(Tasks.getContentUri(mAuthority));
            if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
                sharedContentSet.put(Tasks.TITLE, intent.getStringExtra(Intent.EXTRA_SUBJECT));
            }
            if (intent.hasExtra(Intent.EXTRA_TITLE)) {
                sharedContentSet.put(Tasks.TITLE, intent.getStringExtra(Intent.EXTRA_TITLE));
            }
            if (intent.hasExtra(Intent.EXTRA_TEXT)) {
                String extraText = intent.getStringExtra(Intent.EXTRA_TEXT);
                sharedContentSet.put(Tasks.DESCRIPTION, extraText);
                // check if supplied text is a URL
                if (extraText.startsWith("http://") && !extraText.contains(" ")) {
                    sharedContentSet.put(Tasks.URL, extraText);
                }

            }
            // hand over shared information to EditTaskFragment
            arguments.putParcelable(EditTaskFragment.PARAM_CONTENT_SET, sharedContentSet);

        } else if (ACTION_NOTE_TO_SELF.equals(action)) {
            // process the note to self intent
            ContentSet sharedContentSet = new ContentSet(Tasks.getContentUri(mAuthority));

            if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
                sharedContentSet.put(Tasks.DESCRIPTION, intent.getStringExtra(Intent.EXTRA_SUBJECT));
            }

            if (intent.hasExtra(Intent.EXTRA_TEXT)) {
                String extraText = intent.getStringExtra(Intent.EXTRA_TEXT);
                sharedContentSet.put(Tasks.TITLE, extraText);

            }

            // add start time stamp
            sharedContentSet.put(Tasks.DTSTART, System.currentTimeMillis());
            sharedContentSet.put(Tasks.TZ, TimeZone.getDefault().getID());

            // hand over shared information to EditTaskFragment
            arguments.putParcelable(EditTaskFragment.PARAM_CONTENT_SET, sharedContentSet);

        } else {
            // hand over task URI for editing / creating empty task
            arguments.putParcelable(EditTaskFragment.PARAM_TASK_URI, getIntent().getData());
            ContentSet data = getIntent().getParcelableExtra(EXTRA_DATA_CONTENT_SET);
            if (data != null) {
                arguments.putParcelable(EditTaskFragment.PARAM_CONTENT_SET, data);
            }
            String accountType = getIntent().getStringExtra(EXTRA_DATA_ACCOUNT_TYPE);
            if (accountType != null) {
                arguments.putString(EditTaskFragment.PARAM_ACCOUNT_TYPE, accountType);
            }
        }

        EditTaskFragment fragment = new EditTaskFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction().add(R.id.add_task_container, fragment).commit();

    }

}

From source file:com.iskrembilen.quasseldroid.gui.settings.IdentityActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(ThemeUtil.themeNoActionBar);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_identity);

    Intent i = getIntent();
    if (i.hasExtra("identityId"))
        identityId = i.getIntExtra("identityId", 0);

    mViewPager = (ViewPager) findViewById(R.id.viewpager);

    // Tab Initialization
    tabStrip = (MaterialTabHost) findViewById(R.id.tabs);
    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);/*from w w  w.j  a v  a  2 s  . co  m*/

    // Fragments and ViewPager Initialization
    List<Fragment> fragments = getFragments();
    pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments,
            new String[] { getString(R.string.identity_tab_nicks), getString(R.string.identity_tab_advanced) });
    MaterialTabListener tabListener = new MaterialTabListener() {
        @Override
        public void onTabSelected(MaterialTab materialTab) {
            mViewPager.setCurrentItem(materialTab.getPosition());
            tabStrip.setSelectedNavigationItem(materialTab.getPosition());
        }

        @Override
        public void onTabReselected(MaterialTab materialTab) {
            mViewPager.setCurrentItem(materialTab.getPosition());
            tabStrip.setSelectedNavigationItem(materialTab.getPosition());
        }

        @Override
        public void onTabUnselected(MaterialTab materialTab) {
        }
    };
    mViewPager.setAdapter(pageAdapter);
    for (int j = 0; j < pageAdapter.getCount(); j++) {
        tabStrip.addTab(tabStrip.newTab().setText(pageAdapter.getPageTitle(j)).setTabListener(tabListener));
    }
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            tabStrip.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_check);
}

From source file:com.sir_m2x.messenger.activities.ChatWindowPager.java

@Override
protected void onNewIntent(final Intent intent) {
    if (intent.hasExtra(Utils.qualify("friendId"))) {
        currentFriendId = intent.getExtras().getString(Utils.qualify("friendId"));
        if (!MessengerService.getFriendsInChat().keySet().contains(currentFriendId))
            MessengerService.getFriendIMs(this, currentFriendId);
    } else if (currentFriendId == "" || !MessengerService.getFriendsInChat().keySet().contains(currentFriendId))
        currentFriendId = MessengerService.getFriendsInChat().keySet().toArray()[0].toString();

    for (int i = 0; i < MessengerService.getFriendsInChat().size(); i++)
        if (MessengerService.getFriendsInChat().keySet().toArray()[i].toString().equals(currentFriendId)) {
            currentItem = i;//from   w  w w . j a v a2s  .  co  m
            break;
        }

    MessengerService.getUnreadIMs().remove(currentFriendId);
    this.mTabPageIndicator.setCurrentItem(currentItem);
    this.mViewPager.setCurrentItem(currentItem);
    this.mTabPageIndicator.notifyDataSetChanged();

    // reshow the default notification
    MessengerService.getNotificationHelper().showDefaultNotification(false, false);

    super.onNewIntent(intent);
}

From source file:cm.aptoide.pt.RemoteInSearch.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    mPm = getPackageManager();/*from   w ww  .  j  a v a2  s.  c o m*/
    if (data != null && data.hasExtra("settings")) {
        if (data.hasExtra("align"))
            order_lst = data.getStringExtra("align");
        redraw();
    } else {
        List<PackageInfo> getapks = mPm.getInstalledPackages(0);
        for (PackageInfo node : getapks) {
            if (node.packageName.equalsIgnoreCase(pkginfo.packageName)) {
                db.insertInstalled(apk_lst.get(requestCode).apkid);
                redraw();
                return;
            }
        }
        db.removeInstalled(apk_lst.get(requestCode).apkid);
        redraw();
    }
}

From source file:com.kciray.android.filemanager.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mainActivity = this;
    Global.setContext(this);
    dbHelper = new DBHelper();

    bookmarkManager = BookmarkManager.getInstance();
    bookmarkManager.setMainActivity(this);
    bookmarkManager.loadAllBookmarks();// w  w  w  . j av  a 2s .c o  m

    mainPref = PreferenceManager.getDefaultSharedPreferences(this);
    boolean firstLaunch = mainPref.getBoolean(getStr(R.string.firstLaunch), true);
    if (firstLaunch) {
        setDefaultPrefForActive();
        mainPref.edit().putBoolean(getStr(R.string.firstLaunch), false).commit();
    }
    historyMaxSize = Integer.valueOf(mainPref.getString(getStr(R.string.historyLength), "50"));

    updateEngine();

    String rootSd = Environment.getExternalStorageDirectory().getPath();
    String dir;

    boolean autoSaveLastDir = mainPref.getBoolean(getStr(R.string.autoSaveLastDir), true);
    if (autoSaveLastDir) {
        dir = mainPref.getString(getStr(R.string.autoSaveLastDirStr), rootSd);
    } else {
        dir = rootSd;
    }
    dir = "/";

    Intent launchIntent = getIntent();
    if (launchIntent != null) {
        if (launchIntent.hasExtra(EXTRA_FILE_PATH)) {
            dir = launchIntent.getStringExtra(EXTRA_FILE_PATH);
        }
    }

    devMode = mainPref.getBoolean(getStr(R.string.devMode), false);
    activeDirView = new DirView(this, dir);
    activeDirView.goToDir(FileMgr.getFile(dir));

    navDrawer = new KciNavDrawer<>(this);
    navDrawer.setMainContent(activeDirView);
    navDrawer.registerOnClickItemListener(this);

    navDrawer.registerOnCreatePopupMenuListener((popupMenu, categoryId, data) -> {
        if (categoryId == DrawerCategories.BOOKMARKS.ordinal()) {
            final MenuItem itemDelete = popupMenu.getMenu().add(R.string.delete_bookmark);
            popupMenu.setOnMenuItemClickListener((item) -> {
                if (item == itemDelete) {
                    BookmarkManager.getInstance().deleteBookmark(((ExFile) data).getFullPath());
                }
                return true;
            });
        }
    });

    navDrawer.addCategory(DrawerCategories.SYSTEM, R.string.cat_system);
    navDrawer.addCategory(DrawerCategories.BOOKMARKS, R.string.cat_bookmarks);

    ExFile root = FileMgr.getFile("/");
    addElementToCategory(DrawerCategories.SYSTEM, R.string.root, root);

    ExFile sdCard = FileMgr.getFile(Environment.getExternalStorageDirectory().getAbsolutePath());
    addElementToCategory(DrawerCategories.SYSTEM, R.string.sd_card, sdCard);

    ExFile DCIM = FileMgr.getFile(Environment.getExternalStorageDirectory().getAbsolutePath())
            .append(Eclair.DIRECTORY_DCIM);
    addElementToCategory(DrawerCategories.SYSTEM, R.string.dcim, DCIM);

    ExFile downloads = FileMgr.getFile(Environment.getExternalStorageDirectory().getAbsolutePath())
            .append(Eclair.DIRECTORY_DOWNLOADS);
    addElementToCategory(DrawerCategories.SYSTEM, R.string.downloads, downloads);

    if (devMode) {
        ExFile internalDir = FileMgr.getFile(AppUtils.getInternalDir());
        addElementToCategory(DrawerCategories.SYSTEM, R.string.internal_dir, internalDir);
    }

    drawerToggle = navDrawer.addButtonToActivity(this);
    setContentView(navDrawer);
    mainPref.registerOnSharedPreferenceChangeListener(this);

    bookmarkManager.addBookmarksToNavDrawer();
    configBottomBar();
}

From source file:com.google.codelabs.appauth.MainActivity.java

private void checkIntent(@Nullable Intent intent) {
    if (intent != null) {
        String action = intent.getAction();
        switch (action) {
        case "com.google.codelabs.appauth.HANDLE_AUTHORIZATION_RESPONSE":
            if (!intent.hasExtra(USED_INTENT)) {
                handleAuthorizationResponse(intent);
                intent.putExtra(USED_INTENT, true);
            }/*from   w  ww .  j  a  va2  s  .  c o  m*/
            break;
        default:
            // do nothing
        }
    }
}

From source file:mobisocial.socialkit.musubi.Musubi.java

public DbObj objFromIntent(Intent intent) {
    Log.d(TAG, "fetching obj from " + intent);
    if (intent.hasExtra(EXTRA_OBJ_URI)) {
        try {/*from   w  w w. j av  a  2 s .c o m*/
            Uri objUri = intent.getParcelableExtra(EXTRA_OBJ_URI);
            return objForUri(objUri);
        } catch (Exception e) {
            if (DBG)
                Log.e(TAG, "couldnt get obj from uri", e);
        }
    }
    if (intent.getType() != null && intent.getType().startsWith("vnd.musubi.obj/")) {
        if (intent.getData() != null) {
            return objForUri(intent.getData());
        }
    }
    if (DBG)
        Log.e(TAG, "no obj found");
    return null;
}

From source file:com.hannesdorfmann.search.SearchActivity.java

@Override
  protected void onNewIntent(Intent intent) {
      if (intent.hasExtra(SearchManager.QUERY)) {
          String query = intent.getStringExtra(SearchManager.QUERY);
          if (!TextUtils.isEmpty(query)) {
              searchView.setQuery(query, false);
              searchFor(query);// w  w  w. j  a v  a  2s . c o m
          }
      }
  }

From source file:com.jtechme.apphub.FDroid.java

private void checkForAddRepoIntent(Intent intent) {
    // Don't handle the intent after coming back to this view (e.g. after hitting the back button)
    // http://stackoverflow.com/a/14820849
    if (!intent.hasExtra(ADD_REPO_INTENT_HANDLED)) {
        NewRepoConfig parser = new NewRepoConfig(this, intent);
        if (parser.isValidRepo()) {
            intent.putExtra(ADD_REPO_INTENT_HANDLED, true);
            if (parser.isFromSwap()) {
                Intent confirmIntent = new Intent(this, SwapWorkflowActivity.class);
                confirmIntent.putExtra(SwapWorkflowActivity.EXTRA_CONFIRM, true);
                confirmIntent.setData(intent.getData());
                startActivityForResult(confirmIntent, REQUEST_SWAP);
            } else {
                startActivity(new Intent(ACTION_ADD_REPO, intent.getData(), this, ManageReposActivity.class));
            }//  w  w w  . ja v a2 s .  co m
        } else if (parser.getErrorMessage() != null) {
            Toast.makeText(this, parser.getErrorMessage(), Toast.LENGTH_LONG).show();
        }
    }
}