Fatal Exception Main Error
Merhaba bir sınıfın içine Application sınıfını bağlamaya calısıyorum. Sürekli hata veriyor. Hata şu;
[code]
12-12 18:25:56.977: E/AndroidRuntime(401): FATAL EXCEPTION: main
12-12 18:25:56.977: E/AndroidRuntime(401): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.denemeservis/com.denemeservis.YurtFm}: java.lang.NullPointerException
12-12 18:25:56.977: E/AndroidRuntime(401): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.os.Looper.loop(Looper.java:123)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-12 18:25:56.977: E/AndroidRuntime(401): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 18:25:56.977: E/AndroidRuntime(401): at java.lang.reflect.Method.invoke(Method.java:507)
12-12 18:25:56.977: E/AndroidRuntime(401): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-12 18:25:56.977: E/AndroidRuntime(401): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-12 18:25:56.977: E/AndroidRuntime(401): at dalvik.system.NativeStart.main(Native Method)
12-12 18:25:56.977: E/AndroidRuntime(401): Caused by: java.lang.NullPointerException
12-12 18:25:56.977: E/AndroidRuntime(401): at com.denemeservis.YurtFm.onCreate(YurtFm.java:35)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-12 18:25:56.977: E/AndroidRuntime(401): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-12 18:25:56.977: E/AndroidRuntime(401): ... 11 more
[/code]
AppClass sınıfı içeriği ;
[code]
public class AppClass1 extends Application {
private boolean toggle1;
private boolean toggle2;
public boolean isToggle1() {
return toggle1;
}
public void setToggle1(boolean toggle1) {
this.toggle1 = toggle1;
}
public boolean isToggle2() {
return toggle2;
}
public void setToggle2(boolean toggle2) {
this.toggle2 = toggle2;
}
}
[/code]
Bağlamaya çalıştığım sınıf içeriği ;
[code]
public class YurtFm extends Activity{
protected ToggleButton toggle;
protected AppClass1 app;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.yurt_fm_sayfasi);
app = (AppClass1)getApplicationContext();
toggle.setChecked(app.isToggle1());
toggle = (ToggleButton) findViewById(R.id.toggle1);
toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
app.setToggle1(isChecked);
}
});
}
}
[/code] Xml içeriğim; [code]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:text="YURT FM SAYFASI" />
<ToggleButton
android:id="@+id/toggle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp" />
</RelativeLayout>
[/code] Manifest İçeriğim; [code] <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="com.denemeservis.AppClass1">
<activity
android:name="com.denemeservis.YurtFm"
android:configChanges="orientation"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.Yurt" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
[/code]
Manifest dosyam bıraz kabarık oldugu icin ilgili class ların manifestlerini yazdım.
Teşekkür Ederim.