intent creating problem

Put your problem here if it does not fit any of the other categories.

intent creating problem

Postby ranjit0046 » Fri Jan 22, 2010 1:16 pm

Hi Friends,

i am facing a problem regarding Intent creation, i will try to create an Intent that calls another activity in a thread (run method) , but it shows NullpointerException at the time of calling

this.startActivity(intent);

can u please help anyone how to get rid of this problem, my aim is to call new activity as a separate thread . and stop main thread until it is completed , any one plz help me to solve this problem .

---> i am creating new thread here

newThr nt = new newThr(title,mymessage,softkeyvalue,c);
Thread t= new Thread(nt);
t.start();



---> newThr class is as fallows


public class newThr extends Activity implements Runnable
{
String m_title,m_mymessage;
Context context;
ArrayList <String> m_buttonNames;
public newThr(String m_title,String m_mymessage,ArrayList<String> m_buttonNames,Context c)
{
this.m_title = m_title;
this.m_mymessage = m_mymessage;
this.m_buttonNames =m_buttonNames;
this.context = c;

}

public void run()
{

Log.i("newThr", "settingalertbox_ run before");
Intent i = new Intent(context,MyAlertBox.class);

//i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.i("all values are ",""+m_title+m_mymessage+m_buttonNames.get(0));
i.putExtra("title",m_title);
i.putExtra("message", m_mymessage);
//i.putExtra("buttonNames", 147587121);

i.putStringArrayListExtra("buttonNames",m_buttonNames);

startActivity(i);

//handler.sendEmptyMessage(0);
Log.i("newThr", "settingalertbox_ run after");

}

Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {

Log.i("calling handleMessage ","handleMessage Method in newThr"+context);
/*MyAlertBox b=new MyAlertBox();
b.settingAlertBox(m_title, m_mymessage, m_buttonNames); */
Intent i = new Intent(context,MyAlertBox.class);

//i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.i("all values are ",""+m_title+m_mymessage+m_buttonNames.get(0));
i.putExtra("title",m_title);
i.putExtra("message", m_mymessage);
//i.putExtra("buttonNames", 147587121);

i.putStringArrayListExtra("buttonNames",m_buttonNames);

startActivity(i); //----> here is exception (Nullpointer ) is occured
}
};
}


--> i tried using with out handler it shows same problem plz help me any one ........


Ranjit......
ranjit0046
Developer
Developer
 
Posts: 47
Joined: Mon Dec 14, 2009 12:46 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 16 guests