Skip to main content

Posts

Showing posts from October, 2019

How to Take Screenshot of Current activity and Share Options

Sometimes we have to share the Report or Final receipt Screen  from the Current Application  .In this scenario we take screenshot of Current activity and then share this as image file using sharing Options . So lets move to the Coding Part without wasting time . 1: public class MainActivity extends AppCompatActivity { 2: File imagePath; 3: @Override 4: protected void onCreate(Bundle savedInstanceState) { 5: super.onCreate(savedInstanceState); 6: setContentView(R.layout.activity_main); 7: getSupportActionBar().setDisplayHomeAsUpEnabled(true); 8: ImageView imageView=(ImageView)findViewById(R.id.share); 9: imageView.setOnClickListener(new View.OnClickListener() { 10: @Override 11: public void onClick(View v) { 12: Bitmap bitmap = takeScreenshot(); 13: saveBitmap(bitmap); 14: shareIt(); 15: } 16: }); 17: } 18: public Bitmap takeScreenshot() { 19: View

Android Multi Select Dialog Box

Making Multi Select Dialog box is Pretty Simple and it can be achieved by few lines of coding . So lets move to the Coding Part . Steps: 1.    Create an String Array named "items" 2.   Initialize ArrayList itemsSelected and add if item is selected or remove if not selected . 3.   Get values of selected Items in itemsSelected and use it where ever you want . 1: import android.app.AlertDialog; 2: import android.app.Dialog; 3: import android.content.DialogInterface; 4: import android.os.Bundle; 5: import android.support.v7.app.ActionBarActivity; 6: import java.util.ArrayList; 7: public class MainActivity extends ActionBarActivity { 8: @Override 9: protected void onCreate(Bundle savedInstanceState) { 10: super.onCreate(savedInstanceState); 11: setContentView(R.layout.activity_main); 12: Dialog dialog; 13: final String[] items = {" C", " JAVA", " Kotlin", " Python", &quo