android - How to pass Intent Extras? -


     public class menus extends activity { //set constants mediastore query, , show videos private final static uri media_external_content_uri = mediastore.video.media.external_content_uri; private final static string _id = mediastore.video.media._id; private final static string media_data = mediastore.video.media.data; //flag 1 used images selection private gridview _gallery;  private cursor _cursor; private int _columnindex; private int[] _videosid; private uri _contenturi;   protected context _context; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);      _context = getapplicationcontext();     _gallery = (gridview) findviewbyid(r.id.videogrdvw);     //set default external/sdcard uri     _contenturi = media_external_content_uri;     //initialize videos uri      //showtoast(_contenturi.getpath());     initvideosid();     //set gallery adapter     setgalleryadapter(); } private void setgalleryadapter() {     _gallery.setadapter(new videogalleryadapter(_context));     _gallery.setonitemclicklistener(_itemclicklis);  } private adapterview.onitemclicklistener _itemclicklis = new onitemclicklistener()  {     public void onitemclick(adapterview<?> parent, view v, int position, long id)      {         // want data location of file         string [] proj={media_data};         // request our cursor again         _cursor = managedquery(_contenturi,                 proj, // columns return                 null,       // clause; rows return (all rows)                 null,       // clause selection arguments (none)                 null); // order-by clause (ascending name)         // want column index data uri         int count = _cursor.getcount();         //         _cursor.movetofirst();         //         _columnindex = _cursor.getcolumnindex(media_data);         // lets move selected item in cursor         _cursor.movetoposition(position);          intent = new intent();         i.putextra("mnt/sdcard-ext", _id);         startactivity("com.ave.editor");       } }; 

the above part of second activity. code displays video thumbnails sd card of phone. anyways, when click on thumbnail want item in list clicked open new activity posted below, viewview.

public class editor extends activity {  imagebutton video1; int isclicked = 0; imagebutton audio; int isclicked1 = 0; private string path = "mnt/sdcard-ext"; private videoview mvideoview;      @override protected void oncreate(bundle savedinstancestate) {     // todo auto-generated method stub     super.oncreate(savedinstancestate);     getwindow().setformat(pixelformat.translucent);     setcontentview(r.layout.editor);     mvideoview = (videoview) findviewbyid(r.id.videoview);      int data = getintent().getextras("mnt/sdcard-ext") .getint("com.ave.editor");      if (path == "mnt/sdcard-ext") {         // tell user provide media file url/path.         toast.maketext(                 editor.this,                 "please edit videoviewdemo activity, , set path"                         + " variable media file url/path",                 toast.length_long).show();      } else {          /*          * alternatively,for streaming media can use          * mvideoview.setvideouri(uri.parse(urlstring));          */         mvideoview.setvideopath(path);         mvideoview.setmediacontroller(new mediacontroller(this));         mvideoview.requestfocus();        video1 = (imagebutton) findviewbyid(r.id.video1);     video1.setonclicklistener(new onclicklistener() {          public void onclick(view v) {             if (isclicked == 0) {                 video1.setimageresource(r.drawable.video_pressed);                 isclicked = 1;             } else {                 video1.setimageresource(r.drawable.video1);                 isclicked = 0;             }           }      });      audio = (imagebutton) findviewbyid(r.id.audio);     audio.setonclicklistener(new onclicklistener() {          public void onclick(view v) {             if (isclicked1 == 0) {                 audio.setimageresource(r.drawable.audio_pressed);                 isclicked1 = 1;             } else {                 audio.setimageresource(r.drawable.audio);                 isclicked1 = 0;             }           }       });     }   } } 

as can see don't know how pass intent extras, nor know how them 3rd activity. appreciated. thank you.

====== android manifest ====== (this not full manifest file)

<activity android:name=".menus" android:label="@string/app_name" android:screenorientation="landscape" >       <intent-filter>             <action android:name="com.ave.clearscreen" />             <category android:name="android.intent.category.default" />       </intent-filter> </activity> <activity android:name=".editor" android:screenorientation="landscape" >       <intent-filter>             <action android:name="com.ave.editor" />             <category android:name="android.intent.category.default" />       </intent-filter> </activity> </application> </manifest> 

intent = new intent("com.ave.editor"); i.putextra("mnt/sdcard-ext", _id); startactivity(i); 

and in second activity in oncreate method:

string data = getintent().getstringextra("mnt/sdcard-ext"); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -