vickybat
I am the night...I am...
Guys i'm trying my hands on android programming recently using java and xml.
I know a bit of java but completely new to xml ( i somewhat know html5 and familiar with markup language tags).
Been following a beginners guide and trying to create my first app. Its simply like a "hello-world" code for newbies but prints "batman" instead.
Code is fairly simply as its generated by eclipse linked with android sdk. It creates all the xml and java codes only slightly modified by me.
I'm running this in an emulator and the apk is getting generated and installed and my app icon shows up in the menu screen. But the moment i fire it, it stops and the log throws
a lot of exceptions. Since i'm knew to android, i'm not able to understand the head or tail of the problem since the apk is generated successfully.
I've figured that the problem is in the AndroidManifest.xml file but still cannot figure anything. Posting all the codes separately including one for java and three xml's including the manifest file. Can anybody trace out the problem?? The application stops working when fired.
Java
Strings.xml
activity_main.xml
AndroidManifest.xml
The setContentView method in the java code basically points to the activity_main.xml which has reference with string.xml
Can anybody help me out? This should be simple for android developers here.
I know a bit of java but completely new to xml ( i somewhat know html5 and familiar with markup language tags).
Been following a beginners guide and trying to create my first app. Its simply like a "hello-world" code for newbies but prints "batman" instead.
Code is fairly simply as its generated by eclipse linked with android sdk. It creates all the xml and java codes only slightly modified by me.
I'm running this in an emulator and the apk is getting generated and installed and my app icon shows up in the menu screen. But the moment i fire it, it stops and the log throws
a lot of exceptions. Since i'm knew to android, i'm not able to understand the head or tail of the problem since the apk is generated successfully.
I've figured that the problem is in the AndroidManifest.xml file but still cannot figure anything. Posting all the codes separately including one for java and three xml's including the manifest file. Can anybody trace out the problem?? The application stops working when fired.
Java
Code:
package Test.Android;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">.TestAndroid</string>
<string name="hello_world">Batman </string>
<string name="menu_settings">Settings</string>
</resources>
activity_main.xml
Code:
<RelativeLayout xmlns:android="*schemas.android.com/apk/res/android"
xmlns:tools="*schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="*schemas.android.com/apk/res/android"
package="Test.Android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" android:maxSdkVersion="16"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Test.Android.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The setContentView method in the java code basically points to the activity_main.xml which has reference with string.xml
Can anybody help me out? This should be simple for android developers here.