Example usage for android.content ContentResolver SCHEME_ANDROID_RESOURCE

List of usage examples for android.content ContentResolver SCHEME_ANDROID_RESOURCE

Introduction

In this page you can find the example usage for android.content ContentResolver SCHEME_ANDROID_RESOURCE.

Prototype

String SCHEME_ANDROID_RESOURCE

To view the source code for android.content ContentResolver SCHEME_ANDROID_RESOURCE.

Click Source Link

Usage

From source file:com.danxx.brisktvlauncher.ui.FullScreenVideoActivity.java

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

    mSettings = new Settings(this);

    // handle arguments
    mVideoPath = getIntent().getStringExtra("videoPath");

    Intent intent = getIntent();// w  w w.  j ava2  s  .c o  m
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    //        mMediaController = new AndroidMediaController(this, false);
    //        mMediaController.setSupportActionBar(actionBar);
    customMediaController = new CustomMediaController(this, false);
    customMediaController.setSupportActionBar(actionBar);
    actionBar.setDisplayHomeAsUpEnabled(true);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(customMediaController);
    mVideoView.setHudView(mHudView);
    // prefer mVideoPath
    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }
    mVideoView.start();
}

From source file:com.example.yf.ijkplayerdemo.activities.VideoActivity.java

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

    mSettings = new Settings(this);

    // handle arguments
    mVideoPath = getIntent().getStringExtra("videoPath");

    Intent intent = getIntent();//w  ww  . j av a 2  s .  c o  m
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    mVideoView.setHudView(mHudView);
    // prefer mVideoPath
    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }
    mVideoView.start();
}

From source file:com.wsi.audiodemo.ScrollingActivity.java

private void notifySound(String assetName) {
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    // Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    String RESOURCE_PATH = ContentResolver.SCHEME_ANDROID_RESOURCE + "://";

    String path;//from w w  w  . j a  v a  2s .c  om
    if (false) {
        path = RESOURCE_PATH + getPackageName() + "/raw/" + assetName;
    } else {
        int resID = getResources().getIdentifier(assetName, "raw", getPackageName());
        path = RESOURCE_PATH + getPackageName() + File.separator + resID;
    }
    Uri soundUri = Uri.parse(path);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
            .setContentTitle("Title").setContentText("Message").setSmallIcon(R.mipmap.ic_launcher)
            .setSound(soundUri); //This sets the sound to play

    notificationManager.notify(10, mBuilder.build());
}

From source file:fr.simon.marquis.secretcodes.model.SecretCode.java

private void buildIconUri() {
    if (this.mDrawableResource == 0) {
        mIconUri = null;/*from   www  .  j  a  v a  2 s.  c om*/
    } else {
        Uri.Builder builder = new Uri.Builder();
        builder.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE);
        builder.authority(this.mPackageManager);
        builder.appendPath(Integer.toString(this.mDrawableResource));
        mIconUri = builder.build();
    }
}

From source file:com.hema.playViewUtil.ui.OnlineVideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // ???//from  w ww  .  ja v  a2  s .  c o m
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // ????
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_player);

    mSettings = new Settings(this);

    // handle arguments
    mVideoPath = getIntent().getStringExtra("videoPath");

    Intent intent = getIntent();
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    //        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    //        setSupportActionBar(toolbar);

    //        ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    //        mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);
    loading_icon = (ProgressBar) findViewById(R.id.loading_icon);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);

    mVideoView.setMediaController(mMediaController);
    //        mVideoView.setHudView(mHudView);
    setListener();

    // prefer mVideoPath
    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }
    mVideoView.start();
}

From source file:com.ctg.ctvideo.activities.VideoActivity.java

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

    mSettings = new Settings(this);

    // handle arguments
    mVideoPath = getIntent().getStringExtra("videoUrl");

    Intent intent = getIntent();//  w w w . j  a v  a  2s. c om
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    mVideoView.setHudView(mHudView);

    // 
    mVideoAd = (FrameLayout) findViewById(R.id.video_ad);
    mVideoView.setVideoAd(mVideoAd);
    mVideoView.addVideoAdTask(0, "http://www.pp3.cn/uploads/allimg/111110/15563RI9-7.jpg");
    mVideoView.addVideoAdTask(10000, intent.getStringExtra("videoImg"));
    mVideoView.addVideoAdTask(20000,
            "http://photo.enterdesk.com/2011-2-16/enterdesk.com-1AA0C93EFFA51E6D7EFE1AE7B671951F.jpg");
    mVideoView.addVideoAdTask(15000,
            "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png");

    // prefer mVideoPath
    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }
    mVideoView.start();
}

From source file:enterprayz.megatools.Tools.java

public static Uri ResourceToUri(Context context, int resID) {
    return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
            + context.getResources().getResourcePackageName(resID) + '/'
            + context.getResources().getResourceTypeName(resID) + '/'
            + context.getResources().getResourceEntryName(resID));
}

From source file:com.androidinspain.deskclock.Utils.java

/**
 * @param resourceId identifies an application resource
 * @return the Uri by which the application resource is accessed
 *///  ww  w.  ja  v a  2 s .co m
public static Uri getResourceUri(Context context, @AnyRes int resourceId) {
    return new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE).authority(context.getPackageName())
            .path(String.valueOf(resourceId)).build();
}

From source file:cn.figo.mydemo.ui.activity.VideoActivity.java

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

    mSettings = new Settings(this);

    //      handle arguments
    mVideoPath = getIntent().getStringExtra("videoPath");

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        String scheme = mVideoUri.getScheme();
        if (TextUtils.isEmpty(scheme)) {
            Log.e(TAG, "Null unknown ccheme\n");
            finish();/*from   w ww  . j ava  2 s .  co  m*/
            return;
        }
        if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
            mVideoPath = mVideoUri.getPath();
        } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
            Log.e(TAG, "Can not resolve content below Android-ICS\n");
            finish();
            return;
        } else {
            Log.e(TAG, "Unknown scheme " + scheme + "\n");
            finish();
            return;
        }
    }

    Intent intent = getIntent();
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    new RecentMediaStorage(this).saveUrlAsync(mVideoPath);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    mVideoView.setHudView(mHudView);

    mVideoView.toggleAspectRatio();

    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }

    initDanmaku();

}

From source file:com.wsi.audiodemo.ScrollingActivity.java

private void playSound2(String assetName) {
    try {/* www  .j  av  a  2 s.c  o m*/
        // Syntax  :  android.resource://[package]/[res type]/[res name]
        // Example : Uri.parse("android.resource://com.my.package/raw/sound1");
        //
        // Syntax  : android.resource://[package]/[resource_id]
        // Example : Uri.parse("android.resource://com.my.package/" + R.raw.sound1);

        String RESOURCE_PATH = ContentResolver.SCHEME_ANDROID_RESOURCE + "://";

        String path;
        if (false) {
            path = RESOURCE_PATH + getPackageName() + "/raw/" + assetName;
        } else {
            int resID = getResources().getIdentifier(assetName, "raw", getPackageName());
            path = RESOURCE_PATH + getPackageName() + File.separator + resID;
        }
        Uri soundUri = Uri.parse(path);
        mSoundName.setText(path);

        mMediaPlayer = new MediaPlayer();
        if (true) {
            mMediaPlayer.setDataSource(getApplicationContext(), soundUri);
            mMediaPlayer.prepare();
        } else if (false) {
            // How to load external audio files.
            // "/sdcard/sample.mp3";
            //  "http://www.bogotobogo.com/Audio/sample.mp3";
            mMediaPlayer.setDataSource(path);
            mMediaPlayer.prepare();
        } else {
            ContentResolver resolver = getContentResolver();
            AssetFileDescriptor afd = resolver.openAssetFileDescriptor(soundUri, "r");
            mMediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
            afd.close();
        }

        mMediaPlayer.start();
    } catch (Exception ex) {
        Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
    }
}