erezposner
Lurker
I am new to android , and I am trying to implement a timer that every second calls a "cameraActivity" class that takes a picture and stores it into the sd card.
In the Runnable I am creating a new intent .
I get the following error from the log:
: ERROR/AndroidRuntime(18897): at dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(18897): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(18897): at android.content.ComponentName.<init>(ComponentName.java:75)
ERROR/AndroidRuntime(18897): at android.content.Intent.<init>(Intent.java:2754)
ERROR/AndroidRuntime(18897): at timer.erez.temp.TimertempActivity$1.<init>(TimertempActivity.java:40)
ERROR/AndroidRuntime(18897): at timer.erez.temp.TimertempActivity.<init>(TimertempActivity.java:38)
ERROR/AndroidRuntime(18897): at java.lang.Class.newInstanceImpl(Native Method)
ERROR/AndroidRuntime(18897): at java.lang.Class.newInstance(Class.java:1429)
The following code is:
public class TimertempActivity extends Activity {
private Timer MyTimer;
private Preview preview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyTimer = new Timer();
MyTimer.schedule(new TimerTask(){
@Override
public void run(){
TimerMethod();
}
},0,1000);
}
private void TimerMethod()
{
this.runOnUiThread(Timer_Tick);
}
private Runnable Timer_Tick = new Runnable() {
Intent intent = new Intent(null,CameraActivity.class);
int index=0;
@Override
public void run() {
// TODO Auto-generated method stub
startActivity(intent);
//index=index+1;
}
};
}
In the Runnable I am creating a new intent .
I get the following error from the log:
: ERROR/AndroidRuntime(18897): at dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(18897): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(18897): at android.content.ComponentName.<init>(ComponentName.java:75)
ERROR/AndroidRuntime(18897): at android.content.Intent.<init>(Intent.java:2754)
ERROR/AndroidRuntime(18897): at timer.erez.temp.TimertempActivity$1.<init>(TimertempActivity.java:40)
ERROR/AndroidRuntime(18897): at timer.erez.temp.TimertempActivity.<init>(TimertempActivity.java:38)
ERROR/AndroidRuntime(18897): at java.lang.Class.newInstanceImpl(Native Method)
ERROR/AndroidRuntime(18897): at java.lang.Class.newInstance(Class.java:1429)
The following code is:
public class TimertempActivity extends Activity {
private Timer MyTimer;
private Preview preview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyTimer = new Timer();
MyTimer.schedule(new TimerTask(){
@Override
public void run(){
TimerMethod();
}
},0,1000);
}
private void TimerMethod()
{
this.runOnUiThread(Timer_Tick);
}
private Runnable Timer_Tick = new Runnable() {
Intent intent = new Intent(null,CameraActivity.class);
int index=0;
@Override
public void run() {
// TODO Auto-generated method stub
startActivity(intent);
//index=index+1;
}
};
}