Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suggest you for the following Code wherein i am running my application successfully</p> <p>The Code is as Follows:</p> <p>XML file:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f0f0f0" &gt; &lt;Button android:id="@+id/btnVideoGallery" android:layout_width="75dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="15dp" android:text="@string/gallery" /&gt; &lt;Button android:id="@+id/btnCancel" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_below="@+id/btnVideoGallery" android:layout_centerHorizontal="true" android:layout_marginTop="22dp" android:text="@string/cancel" /&gt; &lt;TextView android:id="@+id/lblDisplayImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/btnCancel" android:layout_centerHorizontal="true" android:layout_marginTop="10dp" android:text="@string/below_this_text_video_will_be_displayed" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#000000" android:textSize="13dp" /&gt; &lt;VideoView android:id="@+id/vvDisplayVideo" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/lblDisplayImage" android:layout_marginTop="15dp" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Java File:</p> <pre><code>import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.MediaController; import android.widget.VideoView; public class VideoActivity extends Activity { private Button btnVideoGallery,btnCancel; private VideoView vvDisplayVideo; /** The Constant PICK_VIDEO. */ private static final int PICK_VIDEO=1; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_options); btnVideoGallery=(Button)findViewById(R.id.btnVideoGallery); vvDisplayVideo=(VideoView)findViewById(R.id.vvDisplayVideo); btnCancel=(Button)findViewById(R.id.btnCancel); vvDisplayVideo.setVisibility(View.GONE); btnVideoGallery.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent video=new Intent(); video.setAction(Intent.ACTION_PICK); video.setType("video/*"); startActivityForResult(video, PICK_VIDEO); } }); btnCancel.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent goStartUp=new Intent(VideoActivity.this, StartUpActivity.class); goStartUp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(goStartUp); finish(); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub if (resultCode==Activity.RESULT_OK &amp;&amp; requestCode == PICK_VIDEO) { vvDisplayVideo.setVisibility(View.VISIBLE); vvDisplayVideo.setVideoURI(data.getData()); vvDisplayVideo.setFocusable(true); MediaController mc=new MediaController(this); vvDisplayVideo.setMediaController(mc); Log.i("True", "Executed"); } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub Intent goStartUp=new Intent(VideoActivity.this, StartUpActivity.class); goStartUp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(goStartUp); finish(); return super.onKeyDown(keyCode, event); } } </code></pre> <p>Also you can modify the Manifest File as per your use:</p> <pre><code>&lt;manifest ... &lt;uses-sdk... /&gt; &lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-permission android:name="android.permission.RECORD_VIDEO" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt; &lt;application ..... &lt;/application&gt; &lt;/manifest&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload