Select chapter



basics (6.papers)
activities (5.papers)
services (2.papers)
threads (2.papers)
receivers (1.papers)
advanced android (2.papers)
SQLite database (1.papers)
adapters (1.papers)
adb and ddms (1.papers)
widgets (1.papers)
fragments (1.papers)
UI (1.papers)
Hide

Sponsored Links


  

android activities interview questions and answers

1
How to pass data between activities? let’s say pass user id, city, and password to next activity and display it.
  1. Intent in = new Intent();
    in.setAction("ACTION"); //this should match with other activity intent-filter
    in.setData(Uri.parse("uid","tech"));
    in.setData(Uri.parse("city","Bangalore"));
    in.setData(Uri.parse("pw","android"));
  2. Intent in = new Intent();
    in.setAction("ACTION"); //this should match with other activity intent-filter
    in.putExtra("uid","tech");
    in.putExtra("city","Bangalore");
    in.putExtra("pw","android");
  3. Intent in = new Intent();
    in.setAction("ACTION"); //this should match with other activity intent-filter
    in.putExtra("tech");
    in.putExtra("Bangalore");
    in.putExtra("android");
  4. Intent in = new Intent();
    in.setAction("ACTION"); //this should match with other activity intent-filter
    in.putExtra("uid");
    in.putExtra("city");
    in.putExtra("pw");
Show Answer
Share Facebook gmail Twitter
2
What is activity in android?
  1. each widget in android is called as an activity.
  2. Each screen in android, with which user interacts is called as an activity.
  3. Every activity will have User Interface. An activity with out UI is impossible.
  4. all are true
Show Answer
Share Facebook gmail Twitter
3
What is intent in android?
  1. Intent is a message passing mechanism between 2 components of android.
  2. Intent is used to start other components. Eg: you can start an activity or a service or you can send a broadcast using intents.
  3. Intents can't be used with content providers.
  4. all are true
Show Answer
Share Facebook gmail Twitter
4
What are the different layouts available in android?
  1. absolute layout
    frame layout
    relative layout
    linear layout
  2. frame layout
    relative layout
    linear layout
    table layout
  3. absolute layout
    frame layout
    relative layout
    linear layout
    table layout
  4. none
Show Answer
Share Facebook gmail Twitter
5
What does below code do? Assume that c contains cursor row of an image
selected by user in gallery.

String path = c.getString(c.getColumnIndex(
                                                    MediaStore.MediaColumns.DATA));
                            File f = new File(path);
String abspath = f.getAbsolutePath();
                                    Bitmap b = BitmapFactory.decodeFile(abspath);
  1. It is fetching the path of that image, and then create bitmap using that path.
  2. it is fetching the path of that image, then converting into absolute path, then creating bitmap with that absolute path using bitmapfactory class.
  3. it is taking one image, and then fetching the path of that image, and getting absolute path of that image finally.
  4. it is taking one image, and then fetching the path of that image, and getting absolute path of that image, then inserting that path into a table.
Show Answer
Share Facebook gmail Twitter
6
What is a context in android?
  1. It is an interface to global information of an application.
  2. contexts are generally used to create a new components or objects, like views. Contexts are also used to start an activity, or service or a receiver.
  3. There are two types of contexts, activity context(this) and applicationcontext. You can obtain application context by getApplicationContext() method.
  4. all are true
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
Show one intent example code in android?
  1. This is the code to start second screen by using explicit intent.
    
    Intent in = new Intent(this, SecondScreen.class);
    startActivity(in);
  2. This is the code to start dialer screen by using implicit intent.
    
    Intent in = new Intent();
    in.setAction(Intent.ACTION_DIAL);
    startActivity(in);
  3. option 1 is an example for implicit intent and option 2 is an example for explicit intent.
  4. both option 1 and option 2 are correct.
Show Answer
Share Facebook gmail Twitter
9
Give one intent example in android?
  1. This is the code to start second screen by using explicit intent.
    
    Intent in = new Intent(this, SecondScreen.class);
    startActivity(in);
  2. This is the code to start dialer screen by using implicit intent.
    
    Intent in = new Intent();
    in.setAction(Intent.ACTION_DIAL);
    startActivity(in);
  3. option 1 is an example for implicit intent and option 2 is an example for explicit intent.
  4. both option 1 and option 2 are correct.
Show Answer
Share Facebook gmail Twitter
10
What is pending intent in android?
  1. An intent that is stick with android system for future users is called as pending intent.
  2. An intent which will be fired or triggered at future point of time by some one else (esp Alarm Manager or Notification Manager) on behalf of your application.
  3. both are true
  4. none
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
12
how to handle key events in android? What is the key event flow?
  1. Keyevents will flow from Activity to UI view. If Activity want, it can block any key event.
  2. Keyevents will flow from Activity to UI view. But Activity will never block event flow, but if it is required UI View can block some event to stop Activity to handle it.
  3. Keyevents will flow from Activity to UI view. But Activity will never block event flow, but UI View can't block event to stop Activity to handle it.
  4. Keyevents will flow from Activity to UI view. But Activity will never block event flow, but if it is required UI View can block some event to stop Activity to handle it. Programmer also can block any Key event to stop UI View to handle it.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
How to rotate an image in ImageView?
  1. Matrix m=new Matrix();
    imageView.setScaleType(ScaleType.MATRIX);  
    m.postRotate((float) angle, pivX, pivY);
    imageView.setImageMatrix(matrix);
  2. final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    
        rotateAnim.setDuration(0);
        rotateAnim.setFillAfter(true);
        imgview.startAnimation(rotateAnim);
  3. both are true
  4. none
Show Answer
Share Facebook gmail Twitter
19
How to take picture from camera in android?
  1. //make a folder "pics" to store pics taken by the camera using this 
    final String directory = Environment.getExternalStoragePublicDirectory                                       (Environment.DIRECTORY_PICTURES) + "/pics/"; 
    File nd = new File(directory); 
    nd.mkdirs();
    
    //what is the picture name?
    String file = directory+"myfile"+".jpg";
    File myFile = new File(file);
    try {
        myFile.createNewFile();
    } catch (IOException e) {}       
    
    Uri myUri = Uri.fromFile(myFile);
    
    //prepare intent for starting camera
    Intent in = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    in.putExtra(MediaStore.EXTRA_OUTPUT, myUri);
    
    startActivityForResult(in, 1);
  2. //make a folder "pics" to store pics taken by the camera using this 
    final String directory = Environment.getExternalStoragePublicDirectory                                       (Environment.DIRECTORY_PICTURES) + "/pics/"; 
    File nd = new File(directory); 
    nd.mkdirs();
    
    //what is the picture name?
    String file = directory+"myfile"+".jpg";
    File myFile = new File(file);
    try {
        myFile.createNewFile();
    } catch (IOException e) {}       
    
    Uri myUri = Uri.fromFile(myFile);
    
    //prepare intent for starting camera
    Intent in = new Intent(MediaStore.ACTION_CAMERA); 
    in.putExtra(MediaStore.EXTRA_OUTPUT, myUri);
    
    startActivityForResult(in, 1);
  3. both are true
  4. none
Show Answer
Share Facebook gmail Twitter
20
How to get current date in android?
  1. Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdate = new SimpleDateFormat("dd-MMM-yyyy");
    String date = sdate.format(cal.getTime());
  2. Calendar cal = Calendar.getInstance(); 
    int sec = c.get(Calendar.SECOND);
  3. SimpleDateFormat dateFmt = new SimpleDateFormat("yyyyMMdd_HHmmss");
    String date = dateFmt.format(new Date());
  4. both option 1 and option 3 are correct
Show Answer
Share Facebook gmail Twitter
Read more papers :