public void process_check()
{
Intent process = new Intent(Service_Activity.this, Process.class);
process.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(process);
}
서비스에서 새로운 액티비티를 불렀습니다...
public class Process extends Activity
{
TextView tv1;
TextView tv;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.process);
Toast.makeText(getApplicationContext(), "ddddddddddddddddddddddddddddddd", Toast.LENGTH_SHORT).show();
LayoutInflater layout = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View lay = layout.inflate(R.layout.process, null);
TextView tv1 = (TextView)lay.findViewById(R.id.process_text);
//tv = (TextView)findViewById(R.id.process_text);
//tv.setText("dhflsdfhlsdfl");
tv1.setText("aaaaaaaa");
Button alram_check = (Button)findViewById(R.id.alram_check);
alram_check.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
System.out.println("끝내기 버튼 안~");
Intent intent = new Intent(getApplication(), Service_Activity.class);
stopService(intent);
}
});
}
}
아무것도 안하고 setContentView(R.layout.process); 만 하면 텍스트랑 버튼 이미지 토스트는 보입니다.
그런데 막상 객체를 가져와서 접근할려고 하면 널포인트가 납니다...tv1.setText("aaaaa"); 부분이요...ㅠ.ㅠ
inflate 로 가져와도 널포인트가 납니다...ㅠ.ㅠ
알려주세요...
process.xml
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:name="@+id/process_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="알람 울리는 페이지"
/>
<Button
android:name="@+id/alram_re"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="알람 미루기"/>
<Button
android:name="@+id/alram_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="알람 끄기"/>
</LinearLayout>
logcat
09-14 04:29:25.659: E/AndroidRuntime(18689): FATAL EXCEPTION: main
09-14 04:29:25.659: E/AndroidRuntime(18689): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.alram/com.example.alram.Process}: java.lang.NullPointerException
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.os.Looper.loop(Looper.java:130)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.app.ActivityThread.main(ActivityThread.java:3729)
09-14 04:29:25.659: E/AndroidRuntime(18689): at java.lang.reflect.Method.invokeNative(Native Method)
09-14 04:29:25.659: E/AndroidRuntime(18689): at java.lang.reflect.Method.invoke(Method.java:507)
09-14 04:29:25.659: E/AndroidRuntime(18689): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
09-14 04:29:25.659: E/AndroidRuntime(18689): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
09-14 04:29:25.659: E/AndroidRuntime(18689): at dalvik.system.NativeStart.main(Native Method)
09-14 04:29:25.659: E/AndroidRuntime(18689): Caused by: java.lang.NullPointerException
09-14 04:29:25.659: E/AndroidRuntime(18689): at com.example.alram.Process.onCreate(Process.java:33)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-14 04:29:25.659: E/AndroidRuntime(18689): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
09-14 04:29:25.659: E/AndroidRuntime(18689): ... 11 more