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:cm.aptoide.pt.RemoteInTab.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    File local_path = new File(LOCAL_PATH);
    if (!local_path.exists())
        local_path.mkdir();/*from  w  w  w.  ja v  a2s. co m*/

    File icon_path = new File(ICON_PATH);
    if (!icon_path.exists())
        icon_path.mkdir();

    db = new DbHandler(this);

    sPref = getSharedPreferences("aptoide_prefs", MODE_PRIVATE);
    prefEdit = sPref.edit();
    prefEdit.putBoolean("update", true);
    prefEdit.commit();

    myTabHost = getTabHost();
    myTabHost.addTab(myTabHost.newTabSpec("avail")
            .setIndicator("Available", getResources().getDrawable(android.R.drawable.ic_menu_add))
            .setContent(new Intent(this, TabAvailable.class)));
    myTabHost.addTab(myTabHost.newTabSpec("inst")
            .setIndicator("Installed", getResources().getDrawable(android.R.drawable.ic_menu_agenda))
            .setContent(new Intent(this, TabInstalled.class)));
    myTabHost.addTab(myTabHost.newTabSpec("updt")
            .setIndicator("Updates", getResources().getDrawable(android.R.drawable.ic_menu_info_details))
            .setContent(new Intent(this, TabUpdates.class)));

    myTabHost.setPersistentDrawingCache(ViewGroup.PERSISTENT_SCROLLING_CACHE);

    Vector<ServerNode> srv_lst = db.getServers();
    if (srv_lst.isEmpty()) {
        Intent call = new Intent(this, ManageRepo.class);
        call.putExtra("empty", true);
        call.putExtra("uri", "http://apps.aptoide.org");
        startActivityForResult(call, NEWREPO_FLAG);
    }

    Intent i = getIntent();
    if (i.hasExtra("uri")) {
        Intent call = new Intent(this, ManageRepo.class);
        call.putExtra("uri", i.getStringExtra("uri"));
        startActivityForResult(call, NEWREPO_FLAG);
    } else if (i.hasExtra("newrepo")) {
        Intent call = new Intent(this, ManageRepo.class);
        call.putExtra("newrepo", i.getStringExtra("newrepo"));
        startActivityForResult(call, NEWREPO_FLAG);
    }
}

From source file:org.zywx.wbpalmstar.platform.push.PushRecieveMsgReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    String packg = intent.getPackage();
    if (TextUtils.isEmpty(packg) || !packg.equals(context.getPackageName().toString())) {
        return;/*from  w w  w .j  a  v a2  s. co m*/
    }
    if (ACTION_PUSH.equals(intent.getAction())) {
        if (intent.hasExtra(PushReportConstants.PUSH_DATA_INFO_KEY)) {
            newPushNotification(context, intent);
        } else {
            oldPushNotification(context, intent);
        }
    }
}

From source file:com.google.android.apps.muzei.gallery.GalleryArtSource.java

@Override
protected void onHandleIntent(Intent intent) {
    super.onHandleIntent(intent);
    if (intent != null && ACTION_PUBLISH_NEXT_GALLERY_ITEM.equals(intent.getAction())) {
        Uri forceUri = null;/*w  w  w.  j a  va  2s .c  om*/
        if (intent.hasExtra(EXTRA_FORCE_URI)) {
            forceUri = intent.getParcelableExtra(EXTRA_FORCE_URI);
        }

        publishNextArtwork(forceUri);
    }
}

From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java

@Override
protected void onResume() {
    super.onResume();

    if (mDrawerLayout != null) {
        final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
        /**//w w w .  java  2 s  .c  o m
         * xinsi
         *
         * Intent.ACTION_PACKAGE_REMOVED:
         * Broadcast Action: An existing application package has been removed from the device.
         *
         * Intent.ACTION_PACKAGE_REPLACED:
         * Broadcast Action: A new version of an application package has been installed,
         * replacing an existing version that was previously installed.
         */
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
        filter.addDataScheme("package");
        registerReceiver(mPackageReceiver, filter);

        new CategoriesUpdater().execute();
    }
    final Intent intent = getIntent();
    if (intent != null) {
        if (intent.hasExtra(EXTRA_SHOW_MENU)) {
            if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) {
                // Intent explicitly set to show menu.
                showMenuIcon();
            }
        } else if (isTopLevelTile(intent)) {
            showMenuIcon();
        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {

    fdroidApp = (FDroidApp) getApplication();
    fdroidApp.applyTheme(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.fdroid);//from w  ww .j av a 2s.c o m
    createViews();

    getTabManager().createTabs();

    // Start a search by just typing
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    Intent intent = getIntent();
    handleSearchOrAppViewIntent(intent);

    if (intent.hasExtra(EXTRA_TAB_UPDATE)) {
        boolean showUpdateTab = intent.getBooleanExtra(EXTRA_TAB_UPDATE, false);
        if (showUpdateTab) {
            getTabManager().selectTab(2);
        }
    }

    Uri uri = AppProvider.getContentUri();
    getContentResolver().registerContentObserver(uri, true, new AppObserver());

    InstallExtensionDialogActivity.firstTime(this);

    // Re-enable once it can be disabled via a setting
    // See https://gitlab.com/fdroid/fdroidclient/issues/435
    //
    // if (UpdateService.isNetworkAvailableForUpdate(this)) {
    //     UpdateService.updateNow(this);
    // }
}

From source file:com.concentricsky.android.khanacademy.app.TopicListActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_topic_list);

    // Set / restore state.
    Intent intent = getIntent();
    topicId = intent != null && intent.hasExtra(PARAM_TOPIC_ID) ? intent.getStringExtra(PARAM_TOPIC_ID)
            : savedInstanceState != null && savedInstanceState.containsKey(PARAM_TOPIC_ID)
                    ? savedInstanceState.getString(PARAM_TOPIC_ID)
                    : null;/*from  w w  w. j av a2s .c om*/
}

From source file:com.lhtechnologies.DoorApp.AuthenticatorService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent.getAction().equals(stopAction)) {
        stopSelf();/*from  w ww .j  ava 2s .  c  o  m*/
    } else if (intent.getAction().equals(authenticateAction)) {
        //Check if we want to open the front door or flat door
        String doorToOpen = FrontDoor;
        String authCode = null;
        if (intent.hasExtra(FlatDoor)) {
            doorToOpen = FlatDoor;
            authCode = intent.getCharSequenceExtra(FlatDoor).toString();
        }

        if (intent.hasExtra(LetIn)) {
            doorToOpen = LetIn;
        }

        //Now run the connection code (Hope it runs asynchronously and we do not need AsyncTask --- NOPE --YES
        urlConnection = null;
        URL url;

        //Prepare the return intent
        Intent broadcastIntent = new Intent(AuthenticationFinishedBroadCast);

        try {
            //Try to create the URL, return an error if it fails
            url = new URL(address);

            if (!url.getProtocol().equals("https")) {
                throw new MalformedURLException("Please only use https protocol!");
            }

            String password = "password";
            KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
            keyStore.load(getResources().getAssets().open("LH Technologies Root CA.bks"),
                    password.toCharArray());

            TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
            tmf.init(keyStore);

            SSLContext context = SSLContext.getInstance("TLS");
            context.init(null, tmf.getTrustManagers(), null);

            urlConnection = (HttpsURLConnection) url.openConnection();
            urlConnection.setSSLSocketFactory(context.getSocketFactory());
            urlConnection.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
            urlConnection.setConnectTimeout(15000);
            urlConnection.setRequestMethod("POST");

            urlConnection.setDoOutput(true);
            urlConnection.setChunkedStreamingMode(0);

            OutputStreamWriter out = new OutputStreamWriter(urlConnection.getOutputStream());

            //Write our stuff to the output stream;
            out.write("deviceName=" + deviceName + "&udid=" + udid + "&secret=" + secret + "&clientVersion="
                    + clientVersion + "&doorToOpen=" + doorToOpen);
            if (doorToOpen.equals(FlatDoor)) {
                out.write("&authCode=" + authCode);
                //Put an extra in so the return knows we opened the flat door
                broadcastIntent.putExtra(FlatDoor, FlatDoor);
            }

            out.close();

            BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));

            //Read the answer
            String decodedString;
            String returnString = "";
            while ((decodedString = in.readLine()) != null) {
                returnString += decodedString;
            }
            in.close();

            broadcastIntent.putExtra(AuthenticatorReturnCode, returnString);

        } catch (MalformedURLException e) {
            broadcastIntent.putExtra(AuthenticatorReturnCode, ClientErrorMalformedURL);
        } catch (Exception e) {
            broadcastIntent.putExtra(AuthenticatorReturnCode, ClientErrorUndefined);
            broadcastIntent.putExtra(AuthenticatorErrorDescription, e.getLocalizedMessage());
        } finally {
            if (urlConnection != null)
                urlConnection.disconnect();
            //Now send a broadcast with the result
            sendOrderedBroadcast(broadcastIntent, null);
            Log.e(this.getClass().getSimpleName(), "Send Broadcast!");
        }
    }

}

From source file:com.zegoggles.smssync.activity.MainActivity.java

private void requestPermissionsIfNeeded() {
    final Intent intent = getIntent();
    if (intent != null && intent.hasExtra(EXTRA_PERMISSIONS)) {
        final String[] permissions = intent.getStringArrayExtra(EXTRA_PERMISSIONS);
        Log.v(TAG, "requesting permissions " + Arrays.toString(permissions));
        ActivityCompat.requestPermissions(this, permissions, REQUEST_PERMISSIONS_BACKUP_SERVICE);
    }/*from w  ww  . ja va  2s.  c o m*/
}

From source file:com.conferenceengineer.android.iosched.ui.tablet.SessionsSandboxMultiPaneActivity.java

private void routeIntent(Intent intent, boolean updateSurfaceOnly) {
    Uri uri = intent.getData();//from   w ww. ja va  2 s . c o  m
    if (uri == null) {
        return;
    }

    if (intent.hasExtra(Intent.EXTRA_TITLE)) {
        setTitle(intent.getStringExtra(Intent.EXTRA_TITLE));
    }

    String mimeType = getContentResolver().getType(uri);

    if (ScheduleContract.Tracks.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load track details
        showFullUI(true);
        if (!updateSurfaceOnly) {
            // TODO: don't assume the URI will contain the track ID
            int defaultViewType = intent.getIntExtra(EXTRA_DEFAULT_VIEW_TYPE,
                    TracksDropdownFragment.VIEW_TYPE_SESSIONS);
            String selectedTrackId = ScheduleContract.Tracks.getTrackId(uri);
            loadTrackList(defaultViewType, selectedTrackId);
            onTrackSelected(selectedTrackId);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_TYPE.equals(mimeType)) {
        // Load a session list, hiding the tracks dropdown and the tabs
        mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            loadSessionList(uri, null);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load session details
        if (intent.hasExtra(EXTRA_MASTER_URI)) {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
            showFullUI(false);
            if (!updateSurfaceOnly) {
                loadSessionList((Uri) intent.getParcelableExtra(EXTRA_MASTER_URI),
                        ScheduleContract.Sessions.getSessionId(uri));
                loadSessionDetail(uri);
            }
        } else {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS; // prepare for onTrackInfo...
            showFullUI(true);
            if (!updateSurfaceOnly) {
                loadSessionDetail(uri);
                loadTrackInfoFromSessionUri(uri);
            }
        }

    }

    updateDetailBackground();
}

From source file:com.miz.mizuu.Main.java

@Override
public void onNewIntent(Intent newIntent) {
    super.onNewIntent(newIntent);

    if (!newIntent.hasExtra("fromUpdate")) {
        Intent i;//w ww. jav  a2s .  c o  m
        if (selectedIndex == MOVIES)
            i = new Intent("mizuu-movie-actor-search");
        else // TV shows
            i = new Intent("mizuu-shows-actor-search");
        i.putExtras(newIntent.getExtras());
        LocalBroadcastManager.getInstance(this).sendBroadcast(i);
    }
}