Search in sources :

Example 46 with Uri

use of android.net.Uri in project Rutgers-Course-Tracker by tevjef.

the class TrackedSectionsFragment method launchMarket.

private void launchMarket() {
    final Uri uri = Uri.parse("market://details?id=" + getParentActivity().getApplicationContext().getPackageName());
    final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri);
    if (getParentActivity().getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0) {
        startActivity(rateAppIntent);
    }
}
Also used : Intent(android.content.Intent) Uri(android.net.Uri)

Example 47 with Uri

use of android.net.Uri in project Shuttle by timusus.

the class VideoCastManager method updateMediaSessionMetadata.

/*
     * On ICS and JB, lock screen metadata is one liner: Title - Album Artist - Album. On KitKat, it
     * has two lines: Title , Album Artist - Album
     */
private void updateMediaSessionMetadata() {
    if ((mMediaSessionCompat == null) || !isFeatureEnabled(CastConfiguration.FEATURE_LOCKSCREEN)) {
        return;
    }
    try {
        MediaInfo info = getRemoteMediaInformation();
        if (info == null) {
            return;
        }
        final MediaMetadata mm = info.getMetadata();
        MediaMetadataCompat currentMetadata = mMediaSessionCompat.getController().getMetadata();
        MediaMetadataCompat.Builder newBuilder = currentMetadata == null ? new MediaMetadataCompat.Builder() : new MediaMetadataCompat.Builder(currentMetadata);
        MediaMetadataCompat metadata = newBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, mm.getString(MediaMetadata.KEY_TITLE)).putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, mContext.getResources().getString(R.string.ccl_casting_to_device, getDeviceName())).putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, mm.getString(MediaMetadata.KEY_TITLE)).putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, mm.getString(MediaMetadata.KEY_SUBTITLE)).putLong(MediaMetadataCompat.METADATA_KEY_DURATION, info.getStreamDuration()).build();
        mMediaSessionCompat.setMetadata(metadata);
        Uri iconUri = mm.hasImages() ? mm.getImages().get(0).getUrl() : null;
        if (iconUri == null) {
            Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.album_art_placeholder);
            mMediaSessionCompat.setMetadata(newBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, bm).build());
        } else {
            if (mMediaSessionIconFetchTask != null) {
                mMediaSessionIconFetchTask.cancel(true);
            }
            mMediaSessionIconFetchTask = new FetchBitmapTask() {

                @Override
                protected void onPostExecute(Bitmap bitmap) {
                    if (bitmap != null && mMediaSessionCompat != null) {
                        MediaMetadataCompat currentMetadata = mMediaSessionCompat.getController().getMetadata();
                        MediaMetadataCompat.Builder newBuilder = currentMetadata == null ? new MediaMetadataCompat.Builder() : new MediaMetadataCompat.Builder(currentMetadata);
                        mMediaSessionCompat.setMetadata(newBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, bitmap).build());
                    }
                    mMediaSessionIconFetchTask = null;
                }
            };
            mMediaSessionIconFetchTask.execute(iconUri);
        }
    } catch (NotFoundException e) {
        LOGE(TAG, "Failed to update Media Session due to resource not found", e);
    } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
        LOGE(TAG, "Failed to update Media Session due to network issues", e);
    }
}
Also used : MediaMetadataCompat(android.support.v4.media.MediaMetadataCompat) NoConnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException) Builder(com.google.android.gms.cast.Cast.CastOptions.Builder) NotFoundException(android.content.res.Resources.NotFoundException) FetchBitmapTask(com.google.android.libraries.cast.companionlibrary.utils.FetchBitmapTask) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) MediaInfo(com.google.android.gms.cast.MediaInfo) MediaMetadata(com.google.android.gms.cast.MediaMetadata) TransientNetworkDisconnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException)

Example 48 with Uri

use of android.net.Uri in project jpHolo by teusink.

the class StartActivityUri method onCreate.

@SuppressLint("NewApi")
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.init();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }
    final SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    final SharedPreferences.Editor editor = settings.edit();
    final Uri data = getIntent().getData();
    // final String scheme = data.getScheme(); // Not needed
    // final String host = data.getHost(); // Not needed
    // final String path = data.getPath(); // Not needed
    final String message = data.getQueryParameter("message");
    editor.putString("UriMessage", message);
    editor.commit();
    if (checkScreenSize().equals("large") || checkScreenSize().equals("xlarge")) {
        initiateApp("tablet");
    } else {
        initiateApp("smartphone");
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint)

Example 49 with Uri

use of android.net.Uri in project Shuttle by timusus.

the class PlaylistUtils method clearPlaylist.

/**
     * Method clearPlaylist.
     *
     * @param context    Context
     * @param playlistId int
     */
public static void clearPlaylist(Context context, int playlistId) {
    final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId);
    context.getContentResolver().delete(uri, null, null);
}
Also used : Uri(android.net.Uri)

Example 50 with Uri

use of android.net.Uri in project Shuttle by timusus.

the class PlaylistUtils method removeFromFavorites.

public static void removeFromFavorites(Context context) {
    Song song = MusicUtils.getSong();
    if (song == null) {
        return;
    }
    Observable.fromCallable(() -> {
        Playlist favoritesPlaylist = Playlist.favoritesPlaylist();
        if (favoritesPlaylist.id >= 0) {
            final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", favoritesPlaylist.id);
            return context.getContentResolver().delete(uri, MediaStore.Audio.Playlists.Members.AUDIO_ID + "=" + song.id, null);
        }
        return 0;
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(numTracksAdded -> {
        if (numTracksAdded > 0) {
            Toast.makeText(context, context.getResources().getString(R.string.song_removed_from_favourites, song.name), Toast.LENGTH_SHORT).show();
            LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(MusicService.InternalIntents.FAVORITE_CHANGED));
        }
    });
}
Also used : Song(com.simplecity.amp_library.model.Song) Playlist(com.simplecity.amp_library.model.Playlist) Intent(android.content.Intent) Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)3406 Intent (android.content.Intent)732 Cursor (android.database.Cursor)466 ContentValues (android.content.ContentValues)349 File (java.io.File)339 IOException (java.io.IOException)254 ContentResolver (android.content.ContentResolver)242 ArrayList (java.util.ArrayList)209 Test (org.junit.Test)194 RemoteException (android.os.RemoteException)190 Bundle (android.os.Bundle)154 Bitmap (android.graphics.Bitmap)129 Context (android.content.Context)118 InputStream (java.io.InputStream)110 PendingIntent (android.app.PendingIntent)104 LargeTest (android.test.suitebuilder.annotation.LargeTest)97 View (android.view.View)95 FileNotFoundException (java.io.FileNotFoundException)94 Request (android.app.DownloadManager.Request)83 TextView (android.widget.TextView)73