Load library Activity with Intent : Intent « Core Class « Android






Load library Activity with Intent

    
package app.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;

public class Test extends Activity 
{
  public static final String tag="HelloWorld";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
      super.onCreateOptionsMenu(menu);
        MenuInflater inflater = getMenuInflater(); //from activity
        inflater.inflate(R.menu.my_menu, menu);
      return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) 
    {
      appendMenuItemText(item);
      if (item.getItemId() == R.id.menu_clear)
      {
        this.emptyText();
        return true;
      }
      if (item.getItemId() == R.id.menu_library_activity)
      {
        this.invokeLibActivity(item.getItemId());
        return true;
      }
      return true;
    }
    
    private void invokeLibActivity(int mid)
    {
    Intent intent = new Intent(this,TestLibActivity.class);
    intent.putExtra("app.test", mid);
    startActivity(intent);
    }
    
    private TextView getTextView()
    {
        return (TextView)this.findViewById(R.id.text1);
    }
    public void appendText(String abc)
    {
        TextView tv = getTextView(); 
        tv.setText(tv.getText() + "\n" + abc);
    }
    
    private void appendMenuItemText(MenuItem menuItem)
    {
       String title = menuItem.getTitle().toString();
       TextView tv = getTextView(); 
       tv.setText(tv.getText() + "\n" + title);
    }
    private void emptyText()
    {
          TextView tv = getTextView();
          tv.setText("");
    }
}

   
    
    
    
  








Related examples in the same category

1.Using Intent to open other Activity
2.Create Intent to open a Uri
3.extends IntentService
4.Phone Intent
5.Map Intent
6.Market Intent
7.Load Activity with Intent
8.Using Intent to make another phone call
9.extends IntentService to create your own Intent
10.Adding data bundle to Intent
11.Using Intent to show other Activities
12.Start Intent with Utility class
13.Capture Image with Intent
14.Intent.ACTION_MEDIA_MOUNTED
15.Using Intent to record audio
16.Video Player Intent
17.Video Capture Intent
18.Implementing an application service that will run in response to an alarm, allowing us to move long duration work out of an intent receiver.
19.Example of various Intent flags to modify the activity stack.
20.Sample code that invokes the speech recognition intent API.
21.extends IntentService to upload a file
22.factory class for generating various intents
23.Open Web Page Intent
24.Is Intent Available
25.start MMS Intent
26.Access the Internet
27.Pdf viewer
28.Rotation One Demo
29.Media activity