Skip to main content

Posts

Showing posts with the label Intent

Implementing Share Intent in Android

Create a sharing button and inside the listen for button click call the share intent Intent sharingIntent = newIntent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = "Insert the share content body"; sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Insert Subject Here"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, "Share via")); Note: Give internet permission in android manifest file < uses-permission android:name="android.permission.INTERNET"/>

Showing Selected Grid Image in New Activity (Full Screen)

in main java class: gridView = (GridView) findViewById(R.id.gridView1); gridView.setAdapter(new ImageAdapter(this)); gridView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent,View v,int position,long id) { System.out.println("====>>"+position); Intent i = new Intent(getApplicationContext(),GidImage.class); // passing array index i.putExtra("id", position); startActivity(i); } }); create a new java file with an image view: Intent i = getIntent(); // Selected image id int position = i.getExtras().getInt("id"); ImageAdapter imageAdapter = new ImageAdapter(this); ImageView imageView =(ImageView) findVi...

Passing Images between Activities in Android

in First Activity: Intent intent=new Intent(FirstClass.this, SecondClass.class); Bundle bundle=new Bundle(); bundle.putInt("image",R.drawable.ic_launcher); intent.putExtras(bundle); startActivity(intent); in Second Acticity: Bundle bundle=this.getIntent().getExtras(); int pic=bundle.getInt("image"); v.setImageResource(pic); another method: in First Activity: Drawable drawable=imgv.getDrawable(); Bitmap bitmap= ((BitmapDrawable)drawable).getBitmap(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] b = baos.toByteArray(); Intent intent=new Intent(Passimage.this,myclass.class); intent.putExtra("picture", b); startActivity(intent); in Second Acticity: Bundle extras = getIntent().getExtras(); byte[] b = extras.getByteArray("picture"); Bitmap bmp = BitmapFactory.decodeByteArray(b, 0, b.lengt...