Example usage for android.content Intent getCharSequenceExtra

List of usage examples for android.content Intent getCharSequenceExtra

Introduction

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

Prototype

public CharSequence getCharSequenceExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static CharSequence getCharSequenceExtra(Intent intent, String name) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return null;
    return intent.getCharSequenceExtra(name);
}

From source file:com.silentcircle.silenttext.activity.AccountCreationActivity.java

private static Bundle copyCharSequence(Intent from, Bundle to, String extra) {
    to.putCharSequence(extra, from.getCharSequenceExtra(extra));
    return to;//from  www.j  a va  2  s .  c o m
}

From source file:com.ephemeraldreams.gallyshuttle.ui.receivers.ArrivalNotificationReceiver.java

private void displayReminderNotification(Context context, Intent intent) {

    CharSequence stationName = intent.getCharSequenceExtra(EXTRA_STATION_NAME);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_directions_bus_white_48dp)
            .setContentTitle(context.getString(R.string.notification_title))
            .setContentText(/* w  ww  .ja va 2  s  .  c o m*/
                    String.format(context.getString(R.string.notification_content), stationName.toString()))
            .setAutoCancel(true);
    if (vibrationEnabledBooleanPreference.get()) {
        builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
    }
    String ringtone = ringtoneChoiceStringPreference.get();
    if (!TextUtils.isEmpty(ringtone)) {
        Uri ringtoneUri = Uri.parse(ringtone);
        builder.setSound(ringtoneUri);
    }
    notificationManager.notify(0, builder.build());
    Timber.d("Notification sent: " + LocalDateTime.now().toLocalTime().toString());
}

From source file:com.grarak.kerneladiutor.fragments.tools.customcontrols.CreateFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == 0 && data != null) {
        CharSequence text = data.getCharSequenceExtra(EditorActivity.TEXT_INTENT);
        if (text != null) {
            mCodeViews.get(mSettings.get(requestCode)).resetTest();
            mCodeViews.get(mSettings.get(requestCode)).setCode(text.toString().trim());
            showFab();/*from   www  . j  a  v a  2 s . c o  m*/
        }
    }
}

From source file:com.grarak.kerneladiutor.fragments.tools.InitdFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (data == null)
        return;/*from  w ww.j  av a  2s.  c  o m*/
    if (requestCode == 0) {
        Initd.write(mEditInitd, data.getCharSequenceExtra(EditorActivity.TEXT_INTENT).toString());
        reload();
    } else if (requestCode == 1) {
        Initd.write(mCreateName, data.getCharSequenceExtra(EditorActivity.TEXT_INTENT).toString());
        mCreateName = null;
        reload();
    }
}

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

@Override
protected void onHandleIntent(Intent intent) {
    if (intent.getAction().equals(stopAction)) {
        stopSelf();//from w  w w .  ja  v a2 s.co 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:org.rm3l.maoni.ui.MaoniActivity.java

private void setAppRelatedInfo() {

    final Intent intent = getIntent();
    final CharSequence callerActivity = intent.getCharSequenceExtra(CALLER_ACTIVITY);
    mAppInfo = new Feedback.App(callerActivity != null ? callerActivity : getClass().getSimpleName(),
            intent.hasExtra(APPLICATION_INFO_BUILD_CONFIG_DEBUG)
                    ? intent.getBooleanExtra(APPLICATION_INFO_BUILD_CONFIG_DEBUG, false)
                    : null,/*from   w  w  w .jav a  2  s.  c om*/
            intent.getStringExtra(APPLICATION_INFO_PACKAGE_NAME),
            intent.getIntExtra(APPLICATION_INFO_VERSION_CODE, -1),
            intent.getStringExtra(APPLICATION_INFO_BUILD_CONFIG_FLAVOR),
            intent.getStringExtra(APPLICATION_INFO_BUILD_CONFIG_BUILD_TYPE),
            intent.hasExtra(APPLICATION_INFO_VERSION_NAME)
                    ? intent.getStringExtra(APPLICATION_INFO_VERSION_NAME)
                    : null);
}

From source file:com.zns.comicdroid.activity.Comics.java

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

    mLvComics = (ListView) findViewById(R.id.comics_lvComics);
    mTvHeading = (TextView) findViewById(R.id.comics_txtHeading);
    mTvEmpty = (TextView) findViewById(R.id.comics_tvEmpty);
    mElvAmazon = (ExpandableListView) findViewById(R.id.comics_elvBooks);
    mElvAmazon.setOnChildClickListener(this);

    mAdapter = new ComicAdapter(this, getImagePath(true));
    mLvComics.setAdapter(mAdapter);/* w  w  w  . ja  v a  2 s  .  co m*/
    mLvComics.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            int comicId = mAdapter.getComicId(position);
            Intent intent = new Intent(Comics.this, ComicView.class);
            intent.putExtra(ComicView.INTENT_COMIC_ID, comicId);
            startActivity(intent);
        }
    });

    Intent intent = getIntent();
    mViewType = intent.getIntExtra(INTENT_COMICS_TYPE, 0);
    mViewWhereValue = intent.getCharSequenceExtra(INTENT_COMICS_VALUE).toString();
    mHeading = intent.getCharSequenceExtra(INTENT_COMICS_HEADING).toString();
    if (mHeading.length() == 0) {
        mHeading = getString(R.string.list_name_na);
    }
    mTvHeading.setText(mHeading);

    if (mViewType == VIEWTYPE_GROUP) {
        mGroupId = intent.getIntExtra(INTENT_COMICS_ID, 0);
        mCurrentGroup = getDBHelper().getGroup(mGroupId);
        mCbIsWatched = (CheckBox) findViewById(R.id.comics_cbWatched);
        mCbIsWatched.setChecked(mCurrentGroup.getIsWatched());
        mCbIsWatched.setOnCheckedChangeListener(this);
        mCbIsFinished = (CheckBox) findViewById(R.id.comics_cbFinished);
        mCbIsFinished.setChecked(mCurrentGroup.getIsFinished());
        mCbIsFinished.setOnCheckedChangeListener(this);
        mCbIsComplete = (CheckBox) findViewById(R.id.comics_cbComplete);
        mCbIsComplete.setChecked(mCurrentGroup.getIsComplete());
        mCbIsComplete.setOnCheckedChangeListener(this);
        mAdapter.mRenderTitle = false;
        findViewById(R.id.comics_group_alts).setVisibility(View.VISIBLE);
        registerForContextMenu(mLvComics);
    } else if (mViewType == VIEWTYPE_READ) {
        findViewById(R.id.comics_ivAmazonsearch).setVisibility(View.GONE);
    }

    //Amazon
    AssociatesAPI.initialize(new AssociatesAPI.Config(getString(R.string.key_amazon_appkey), this));

    //Restore State
    if (savedInstanceState != null && savedInstanceState.containsKey(STATE_BOOKS)) {
        ArrayList<Book> books = savedInstanceState.getParcelableArrayList(STATE_BOOKS);
        if (books != null) {
            mAmazonAdapter = new ExpandableAmazonAdapter(this, books);
            mElvAmazon.setAdapter(mAmazonAdapter);
            mElvAmazon.setVisibility(View.VISIBLE);
        }
    }
}

From source file:ca.rmen.android.poetassistant.main.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    Log.d(TAG, "onNewIntent() called with: " + "intent = [" + intent + "]");
    setIntent(intent);/*from  w  ww.  j av  a 2  s . c o m*/
    // The user entered a search term either by typing or by voice
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getDataString();
        if (TextUtils.isEmpty(query)) {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if (TextUtils.isEmpty(query)) {
            CharSequence userQuery = intent.getCharSequenceExtra(SearchManager.USER_QUERY);
            if (!TextUtils.isEmpty(userQuery))
                query = userQuery.toString();
        }
        if (TextUtils.isEmpty(query))
            return;
        mSearch.addSuggestions(query);
        mSearch.search(query);
    }
    // We got here from a deep link
    else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri data = getIntent().getData();
        handleDeepLink(data);
    }
    // Play some text in the tts tab
    else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        mBinding.viewPager.setCurrentItem(mPagerAdapter.getPositionForTab(Tab.READER));
        String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
        ReaderFragment readerFragment = (ReaderFragment) mPagerAdapter.getFragment(mBinding.viewPager,
                Tab.READER);
        readerFragment.setText(sharedText);
    }
}

From source file:org.rm3l.maoni.ui.MaoniActivity.java

private void initScreenCaptureView(@NonNull final Intent intent) {
    final ImageButton screenshotThumb = (ImageButton) findViewById(R.id.maoni_screenshot);

    final TextView touchToPreviewTextView = (TextView) findViewById(R.id.maoni_screenshot_touch_to_preview);
    if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) {
        touchToPreviewTextView.setText(intent.getCharSequenceExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT));
    }//from  ww w. j a  va  2  s. c  om

    final View screenshotContentView = findViewById(R.id.maoni_include_screenshot_content);
    if (!TextUtils.isEmpty(mScreenshotFilePath)) {
        final File file = new File(mScreenshotFilePath.toString());
        if (file.exists()) {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.VISIBLE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.VISIBLE);
            }
            if (screenshotThumb != null) {
                //Thumbnail - load with smaller resolution so as to reduce memory footprint
                screenshotThumb.setImageBitmap(
                        ViewUtils.decodeSampledBitmapFromFilePath(file.getAbsolutePath(), 100, 100));
            }

            // Hook up clicks on the thumbnail views.
            if (screenshotThumb != null) {
                screenshotThumb.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        final Dialog imagePreviewDialog = new Dialog(MaoniActivity.this);

                        imagePreviewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        imagePreviewDialog.getWindow()
                                .setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

                        imagePreviewDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialogInterface) {
                                //nothing;
                            }
                        });

                        imagePreviewDialog.setContentView(R.layout.maoni_screenshot_preview);

                        final View.OnClickListener clickListener = new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                imagePreviewDialog.dismiss();
                            }
                        };

                        final ImageView imageView = (ImageView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image);
                        imageView.setImageURI(Uri.fromFile(file));

                        final DrawableView drawableView = (DrawableView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image_drawable_view);
                        final DrawableViewConfig config = new DrawableViewConfig();
                        // If the view is bigger than canvas, with this the user will see the bounds
                        config.setShowCanvasBounds(true);
                        config.setStrokeWidth(57.0f);
                        config.setMinZoom(1.0f);
                        config.setMaxZoom(1.0f);
                        config.setStrokeColor(mHighlightColor);
                        final View decorView = getWindow().getDecorView();
                        config.setCanvasWidth(decorView.getWidth());
                        config.setCanvasHeight(decorView.getHeight());
                        drawableView.setConfig(config);
                        drawableView.bringToFront();

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_highlight_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mHighlightColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_blackout_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mBlackoutColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_close)
                                .setOnClickListener(clickListener);

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_undo)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        drawableView.undo();
                                    }
                                });

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_save)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        ViewUtils.exportViewToFile(MaoniActivity.this,
                                                imagePreviewDialog.findViewById(
                                                        R.id.maoni_screenshot_preview_image_view_updated),
                                                new File(mScreenshotFilePath.toString()));
                                        initScreenCaptureView(intent);
                                        imagePreviewDialog.dismiss();
                                    }
                                });

                        imagePreviewDialog.setCancelable(true);
                        imagePreviewDialog.setCanceledOnTouchOutside(false);

                        imagePreviewDialog.show();
                    }
                });
            }
        } else {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.GONE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.GONE);
            }
        }
    } else {
        if (mIncludeScreenshot != null) {
            mIncludeScreenshot.setVisibility(View.GONE);
        }
        if (screenshotContentView != null) {
            screenshotContentView.setVisibility(View.GONE);
        }
    }
}