Example usage for android.content Intent getDataString

List of usage examples for android.content Intent getDataString

Introduction

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

Prototype

public @Nullable String getDataString() 

Source Link

Document

The same as #getData() , but returns the URI as an encoded String.

Usage

From source file:it.gulch.linuxday.android.services.AlarmIntentService.java

private void notifyEvent(Intent intent) {
    long eventId = Long.parseLong(intent.getDataString());
    Event event = eventManager.get(eventId);
    if (event == null) {
        return;//  w  w w .  j  ava  2  s  .c o  m
    }

    //      NotificationManager notificationManager = (NotificationManager) getSystemService(Context
    // .NOTIFICATION_SERVICE);

    //      PendingIntent eventPendingIntent =
    //            TaskStackBuilder.create(this).addNextIntent(new Intent(this,
    // MainActivity.class)).addNextIntent(
    //                  new Intent(this, EventDetailsActivity.class).setData(Uri.parse(String.valueOf(event
    // .getId()))))
    //                  .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    PendingIntent eventPendingIntent = TaskStackBuilder.create(this)
            .addNextIntent(new Intent(this, MainActivity.class))
            .addNextIntent(new Intent(this, EventDetailsActivity.class)
                    .setData(Uri.parse(String.valueOf(event.getId()))))
            .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    int defaultFlags = Notification.DEFAULT_SOUND;
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (sharedPreferences.getBoolean(SettingsFragment.KEY_PREF_NOTIFICATIONS_VIBRATE, false)) {
        defaultFlags |= Notification.DEFAULT_VIBRATE;
    }

    String trackName = event.getTrack().getTitle();
    CharSequence bigText;
    String contentText;
    if (CollectionUtils.isEmpty(event.getPeople())) {
        contentText = trackName;
        bigText = event.getSubtitle();
    } else {
        String personsSummary = StringUtils.join(event.getPeople(), ", ");
        contentText = String.format("%1$s - %2$s", trackName, personsSummary);
        String subTitle = event.getSubtitle();

        SpannableString spannableBigText;
        if (TextUtils.isEmpty(subTitle)) {
            spannableBigText = new SpannableString(personsSummary);
        } else {
            spannableBigText = new SpannableString(String.format("%1$s\n%2$s", subTitle, personsSummary));
        }

        // Set the persons summary in italic
        spannableBigText.setSpan(new StyleSpan(Typeface.ITALIC),
                +spannableBigText.length() - personsSummary.length(), spannableBigText.length(),
                +Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        bigText = spannableBigText;
    }

    String roomName = event.getTrack().getRoom().getName();
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher).setWhen(event.getStartDate().getTime())
            .setContentTitle(event.getTitle()).setContentText(contentText)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(bigText).setSummaryText(trackName))
            .setContentInfo(roomName).setContentIntent(eventPendingIntent).setAutoCancel(true)
            .setDefaults(defaultFlags).setPriority(NotificationCompat.PRIORITY_HIGH);

    // Blink the LED with FOSDEM color if enabled in the options
    if (sharedPreferences.getBoolean(SettingsFragment.KEY_PREF_NOTIFICATIONS_LED, false)) {
        notificationBuilder.setLights(getResources().getColor(R.color.maincolor), 1000, 5000);
    }

    /*// Android Wear extensions
    NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
            
    // Add an optional action button to show the room map image
    int roomImageResId = getResources()
    .getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable", getPackageName());
    if(roomImageResId != 0) {
       // The room name is the unique Id of a RoomImageDialogActivity
       Intent mapIntent = new Intent(this, RoomImageDialogActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
       .setData(Uri.parse(roomName));
       mapIntent.putExtra(RoomImageDialogActivity.EXTRA_ROOM_NAME, roomName);
       mapIntent.putExtra(RoomImageDialogActivity.EXTRA_ROOM_IMAGE_RESOURCE_ID, roomImageResId);
       PendingIntent mapPendingIntent =
       PendingIntent.getActivity(this, 0, mapIntent, PendingIntent.FLAG_UPDATE_CURRENT);
       CharSequence mapTitle = getString(R.string.room_map);
       notificationBuilder
       .addAction(new NotificationCompat.Action(R.drawable.ic_action_place, mapTitle, mapPendingIntent));
       // Use bigger action icon for wearable notification
       wearableExtender.addAction(
       new NotificationCompat.Action(R.drawable.ic_place_white_wear, mapTitle, mapPendingIntent));
    }
            
    notificationBuilder.extend(wearableExtender);*/

    NotificationManagerCompat.from(this).notify((int) eventId, notificationBuilder.build());
}

From source file:net.ustyugov.jtalk.activity.vcard.SetVcardActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == IMAGE && data != null) {
            Uri uri = Uri.parse(data.getDataString());
            if (uri != null) {
                try {
                    FileInputStream fileInput = getContentResolver().openAssetFileDescriptor(uri, "r")
                            .createInputStream();
                    bytes = new byte[fileInput.available()];
                    fileInput.read(bytes);
                    Bitmap bm = Bitmap.createScaledBitmap(BitmapFactory.decodeFileDescriptor(fileInput.getFD()),
                            240, 240, true);
                    av.setImageBitmap(bm);
                    fileInput.close();//from  w  w  w .j av  a 2 s .co  m
                } catch (FileNotFoundException e) {
                } catch (IOException e) {
                }
            }
        }
    }
}

From source file:com.kbeanie.imagechooser.api.VideoChooserManager.java

@SuppressLint("NewApi")
private void processCameraVideo(Intent intent) {
    String path;//from   ww w.ja  v  a 2  s .  com
    int sdk = Build.VERSION.SDK_INT;
    if (sdk >= Build.VERSION_CODES.GINGERBREAD && sdk <= Build.VERSION_CODES.GINGERBREAD_MR1) {
        path = intent.getDataString();
    } else {
        path = filePathOriginal;
    }
    VideoProcessorThread thread = new VideoProcessorThread(path, foldername, shouldCreateThumbnails);
    thread.clearOldFiles(clearOldFiles);
    thread.setListener(this);
    thread.setContext(getContext());
    thread.start();
}

From source file:com.amytech.android.library.views.imagechooser.api.VideoChooserManager.java

@SuppressLint("NewApi")
private void processCameraVideo(Intent intent) {
    String path = null;/*from   w  ww . j  a v a2 s.c o m*/
    int sdk = Build.VERSION.SDK_INT;
    if (sdk >= Build.VERSION_CODES.GINGERBREAD && sdk <= Build.VERSION_CODES.GINGERBREAD_MR1) {
        path = intent.getDataString();
    } else {
        path = filePathOriginal;
    }
    VideoProcessorThread thread = new VideoProcessorThread(path, foldername, shouldCreateThumbnails);
    thread.setListener(this);
    thread.setContext(getContext());
    thread.start();
}

From source file:it.gulch.linuxday.android.activities.EventDetailsActivity.java

@Override
public Loader<Event> onCreateLoader(int id, Bundle args) {
    Intent intent = getIntent();
    String eventIdString;/*  w  w  w .j a v  a2s.  c om*/
    if (NfcUtils.hasAppData(intent)) {
        // NFC intent
        eventIdString = new String(NfcUtils.extractAppData(intent));
    } else {
        // Normal in-app intent
        eventIdString = intent.getDataString();
    }

    return new EventLoader(this, Long.parseLong(eventIdString));
}

From source file:com.cars.manager.utils.imageChooser.api.VideoChooserManager.java

@SuppressLint("NewApi")
private void processCameraVideo(Intent intent) {
    String path = null;//from   ww  w  .j a va 2 s.c  o  m
    int sdk = Build.VERSION.SDK_INT;
    if (sdk >= Build.VERSION_CODES.GINGERBREAD && sdk <= Build.VERSION_CODES.GINGERBREAD_MR1) {
        path = intent.getDataString();
    } else {
        path = filePathOriginal;
    }
    VideoProcessorThread thread = new VideoProcessorThread(path, foldername, shouldCreateThumbnails);
    thread.setListener(this);
    if (activity != null) {
        thread.setContext(activity.getApplicationContext());
    } else if (fragment != null) {
        thread.setContext(fragment.getActivity().getApplicationContext());
    } else if (appFragment != null) {
        thread.setContext(appFragment.getActivity().getApplicationContext());
    }
    thread.start();
}

From source file:com.example.easyvoice.MessageDetail.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i(getClass().getSimpleName(), "request " + requestCode + ", result " + resultCode);
    if (resultCode == Activity.RESULT_OK && requestCode == 0) {
        String result = data.getDataString();
        Toast.makeText(this, result, Toast.LENGTH_LONG).show();
    }//from   w  w w  . j a v a2s.c  o  m
}

From source file:org.quantumbadger.redreader.activities.CommentListingActivity.java

public void onCreate(final Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    OptionsMenuUtility.fixActionBar(this, getString(R.string.app_name));

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT;

    // TODO load from savedInstanceState

    final View layout = getLayoutInflater().inflate(R.layout.main_single);
    if (solidblack)
        layout.setBackgroundColor(Color.BLACK);
    setContentView(layout);//from ww  w.  j av a  2s .  co m

    RedditAccountManager.getInstance(this).addUpdateListener(this);

    if (getIntent() != null) {

        final Intent intent = getIntent();

        if (intent.hasExtra("postId")) {
            final String postId = intent.getStringExtra("postId");
            controller = new CommentListingController(postId, this);

        } else {

            url = intent.getDataString();
            controller = new CommentListingController(Uri.parse(url), this);
        }

        doRefresh(RefreshableFragment.COMMENTS, false);

    } else {
        throw new RuntimeException("Nothing to show! (should load from bundle)"); // TODO
    }
}

From source file:com.google.samples.search.recipe_app.client.RecipeActivity.java

protected void onNewIntent(Intent intent) {
    String action = intent.getAction();
    String data = intent.getDataString();
    if (Intent.ACTION_VIEW.equals(action) && data != null) {
        String recipeId = data.substring(data.lastIndexOf("/") + 1);
        Uri contentUri = RecipeContentProvider.CONTENT_URI.buildUpon().appendPath(recipeId).build();
        showRecipe(contentUri);//from  www. j a va  2 s  . com
    }
}

From source file:com.ryan.ryanreader.activities.CommentListingActivity.java

public void onCreate(final Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    OptionsMenuUtility.fixActionBar(this, getString(R.string.app_name));

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT;

    // TODO load from savedInstanceState

    final View layout = getLayoutInflater().inflate(R.layout.main_single);
    if (solidblack)
        layout.setBackgroundColor(Color.BLACK);
    setContentView(layout);//from  ww  w.j  a  v a2 s  .  com

    RedditAccountManager.getInstance(this).addUpdateListener(this);

    if (getIntent() != null) {

        final Intent intent = getIntent();

        if (intent.hasExtra("postId")) {
            final String postId = intent.getStringExtra("postId");
            controller = new CommentListingController(postId, this);

        } else {

            final String url = intent.getDataString();
            controller = new CommentListingController(Uri.parse(url), this);
        }

        doRefresh(RefreshableFragment.COMMENTS, false);

    } else {
        throw new RuntimeException("Nothing to show! (should load from bundle)"); // TODO
    }
}