java lang runtime exception :unable start activity component info - java

hi sir I got this error when my app was launched. When I run my project unfortunately project was stop. This error is coming my log cat. When click on app unfortunately app was stop msg came.
I put one text view on activity_xml. When click on navigate to another page but here do not display my first page. There is problem to on mainactivity.java and activity main.xml
error is java.lang.runtime Exception: Unable to start activity component Info{com.example.b/com.example.b.MainActivity}: java. Lang.NullPointerException
**mainactivity.java**
andheri = (TextView) findViewById(R.id.Andheri1);
andheri.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Context context = null;
// TODO Auto-generated method stub
Intent intent = new Intent(context,andheri.class);
startActivity(intent);
}
});
**activity_xml**
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/untitled1"
>
<TextView
android:id="#+id/Andher1"
android:layout_width="80dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#FFE4B5"
android:capitalize="characters"
android:gravity="center"
android:text="Andheri"
android:textColor="#000000"
android:textColorHint="#0000CD"
android:textSize="15dp"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
**mainifest file.**
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.b.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>
<activity
android:name="com.example.b.andheri"
android:label="#string/app_name" >
</activity>
</application>

You should change this
andheri = (TextView) findViewById(R.id.Andheri1);
to
andheri = (TextView) findViewById(R.id.Andher1);
Your TextView id is id/Andher1 and you're trying to find it as #+id/Andheri1. So you got NPE.

In the intent you send from main activity, you should set the context to this, not null
and change the id of textview , you missed an 'i'

Related

scroll activity page when key board is open android

I want that whent the soft key board is open the activity page will scrolled.
To do this I added scroll View in xml,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.trying.MainActivity"
>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="#+id/LayoutBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/background"
>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" >
<requestFocus />
</EditText>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
and changed the realativeLayout height in code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int height = size.y;
int x=getActionBarHeight();//in this line I get the actionBar height programicaly the function is in the end of page
RelativeLayout l= (RelativeLayout)findViewById(R.id.LayoutBackground);
l.getLayoutParams().height = (height-x);//the layout size = size of full screen - size of actionBar
}
//I saw this function in stackOverflow site. function to get the actionBar height
public int getActionBarHeight() {
TypedValue tv = new TypedValue();
getApplicationContext().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
int actionBarHeight = getResources().getDimensionPixelSize(tv.resourceId);
return actionBarHeight;
}
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.trying"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The idia is that the layout heigt is depended of screen size (all devices), and action bar heigt too.
My problem is that when I run the app, the background is small.
the it's It seems that the action bar size fell twice,
Add the following line of code to your manifest for the particular activity
android:windowSoftInputMode="adjustResize"
You don't need to add ScrollView in your layout. Remove it from xml. Then in AndroidManifest.xml, add the following lines in your activity:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

One of the two setContentView() not working

This is the code I have written. I have implemented LocationListener methods which I did not paste here. I felt it is unnecessary.
Here I want the activity_main.xml to be displayed for the first launch. So I used SharedPreferences as explained here. Even when the app is launched for the first time, the activity_main.xml is not showing up. The Toast notification saying Registration started is displayed so I know the if statement is getting executed. I can't figure out why activity_map is always loading.
public class MainActivity extends Activity implements LocationListener{
EditText d_name,d_phone,d_email;
Button submit=null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences pref = getSharedPreferences("hello", MODE_PRIVATE);
if(pref.getBoolean("firststart", true)){
//Checking weather this is executed or not
Toast.makeText(getApplicationContext(), "Registration started",
Toast.LENGTH_LONG).show();
//setting layout on the screen
setContentView(R.layout.activity_main);
// update sharedpreference - another start wont be the first
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean("firststart", false);
editor.commit(); // apply changes
// first start, show your dialog | first-run code goes here
d_name = (EditText)findViewById(R.id.d_name);
d_phone = (EditText)findViewById(R.id.d_phone);
d_email = (EditText) findViewById(R.id.d_mail);
submit = (Button) findViewById(R.id.submit);
submit.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
final String name = d_name.getText().toString();
final long ph =Long.parseLong(d_phone.getText().toString());
final String mail = d_email.getText().toString();
'
'
.(Save to db)
}});
}
setContentView(R.layout.activity_map);
initializeMap();
}
If needed, this is my xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TextView
android:layout_centerHorizontal="true"
android:id="#+id/details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="#string/details"
android:textSize="20sp" />
<EditText
android:id="#+id/d_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_name"
android:layout_below="#id/details"
android:inputType="text" />
<EditText
android:id="#+id/d_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/d_name"
android:layout_marginTop="26dp"
android:ems="10"
android:hint="#string/hint_phone"
android:inputType="phone" />
<EditText
android:id="#+id/d_mail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/d_phone"
android:layout_marginTop="26dp"
android:hint="#string/hint_email"
android:inputType="textEmailAddress" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/d_mail"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:hint="#string/button" />
</RelativeLayout>
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prasad.currentlocator"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBLG6F6G8Yi9MYDPdyetgSVgXxhVNYIdyw" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MapActivity"
android:label="#string/title_activity_map" >
</activity>
</application>
</manifest>
This
setContentView(R.layout.activity_map);
is always getting called because it runs after everythin g in if. You need an if/else
if(pref.getBoolean("firststart", true)){
// do all your stuff
} else {
setContentView(R.layout.activity_map);
// do anything else that should run if not first start
}
setContentView() is called twice in your code. Make sure that in your onCreate() the setContentView() is encountered only once in all flows. Here you need to have an else statement.
From my experience, I would suggest that you call setContentView() outside the If/Else, i.e, have just one layout. Then, based on the condition alter the stuff inside the layout. I suggest this, because this would later become a maintenance nightmare.
You are putting wrong setContentView(R.layout.activity_map); . Little mistake in your statement .
Where is your else {} Part
At first Set if-else block properly .

Android: Application is crashing On Startup

I am a novice and I'm just creating a simple Android app in which there are 2 buttons that take you to different pages when clicked, which have different functions.
However, my app crashes on start-up, simply saying
Unfortunately [app name] has stopped
and I don't understand
As I have barely made any changes to my MainActivity.java, the code seems to be well written, and eclipse displays no errors... Any help, please? I have searched around Stack, but I can't find anything specific to this...
Here is my MainActivity.java:
package com.example.helper;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
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.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**Called upon when the user clicks the 'Abbreviations' button*/
public void listDefinitions (View view){
Intent intent = new Intent(this, ListDefinitions.class);
startActivity(intent);
}
/**Called upon when the user clicks the 'Assistant' button*/
public void openAssistant (View view){
Intent intent = new Intent(this, Assistant.class);
startActivity(intent);
}
}
Here is my activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.legittest.MainActivity" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/intro_title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="21.5sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/title"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:text="#string/module_selection"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/definitions_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginLeft="34dp"
android:layout_marginTop="111dp"
android:text="#string/definitions"
android:onClick="listDefinitions" />
<Button
android:id="#+id/assistant_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/definitions_button"
android:layout_centerHorizontal="true"
android:layout_marginTop="56dp"
android:text="#string/assistant"
android:onClick="openAssistant" />
<TextView
android:id="#+id/definitions_explainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/definitions_button"
android:layout_centerHorizontal="true"
android:text="#string/definitions_info"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/greycolor" />
<TextView
android:id="#+id/pa_explainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/definitions_explainer"
android:layout_below="#+id/assistant_button"
android:text="#string/assistant_info"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/greycolor" />
</RelativeLayout>
My ListDefinitions.java & Assistant.java are untouched at this point.
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.theocratichelper"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
<activity
android:name=".ListDefinitions"
android:label="#string/title_activity_list_definitions"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.theocratichelper.MainActivity" />
</activity>
<activity
android:name=".PreachAssistant"
android:label="#string/title_activity_preach_assistant"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.theocratichelper.MainActivity" />
</activity>
</application>
</manifest>
It's your manifest, replace the "last" activity in your manifest by this :
<activity
android:name=".Assistant"
android:label="#string/title_activity_preach_assistant"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.theocratichelper.MainActivity" />
</activity>
Your class name is Assistant and not PreachAssistant i presume.
Just replace the last activity in Android Manifest by this.
<activity
android:name=".Assistant"
android:label="#string/title_activity_preach_assistant"
</activity>

Swapping screens with button. Crashes

I have been messing around with this for a few days now and have the code identical to that in the tutorial and yet it still doesn't want to work, Why?
MainActivity.java
package com.example.mdpmk1;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
public class MainActivity extends Activity {
Button button;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addListenerOnButton();
}
public void addListenerOnButton() {
final Context context = this;
button = (Button) findViewById(R.id.scan);
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, ScanScreen.class);
startActivity(intent);
}
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Screen One......"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/scan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click me to another screen" />
</LinearLayout>
ScanScreen.java
package com.example.mdpmk1;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
public class ScanScreen extends Activity {
Button button;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scan_screen);
}
}
scan_screen.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You have done it!!"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
AndroidMainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.firstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.firstapp.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>
Any help would be lovely, This has relay been annoying me and i know that it is probably a simple mistake.
Add the following in your AndroidManifest.xml
<activity android:name=".ScanScreen" />
within application like so:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.firstapp.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>
<activity android:name=".ScanScreen" />
</application>
Here is a quote from the official docs on what the activity tags are for:
Declares an activity (an Activity subclass) that implements part of
the application's visual user interface. All activities must be
represented by elements in the manifest file. Any that are
not declared there will not be seen by the system and will never be
run.
That last sentence is important.
In your case writing <activity android:name=".ScanScreen" /> above </application> will solve your problem.
Whenever you need to use any activity in android you have to mention it in AndroidManifest.xml file. Just giving answer to you won't help you.
You should first read on below links to understand what is intent and intent-filters used for.
http://developer.android.com/reference/android/content/Intent.html
http://developer.android.com/guide/components/intents-filters.html
What is an Intent in Android?
Your app crashes because your not setting or registered the activity in manifest.You haven't added the ScanScreen Activity in your manifest file.
Just add the following to your AndroidManifest.xml :
<activity android:name=".ScanScreen" />
within your application tag like this:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.firstapp.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>
<activity android:name=".ScanScreen" />
</application>

Android Getting Runtime Error While Starting App

I'm trying to launch my app but i'm getting runtime error all the time.
Definition of the program is: App starts when user clicks button , button will be invisible and count down starts after countdown finish Menu.java will open.
Here is my code below:
Main.java
public class Main extends Activity {
TextView countDown;
int counter;
Intent menuIntent;
Button appStartButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
menuIntent = new Intent("com.example.project_21.MENU");
counter = 5;
countDown = (TextView) findViewById(R.id.countDown);
appStartButton = (Button) findViewById(R.id.appStartButton);
appStartButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
v.setVisibility(View.GONE);
while (counter != 0) {
sleep(1000);
counter--;
countDown.setText(counter + " seconds");
}
startActivity(menuIntent);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sleep(long mill) {
try {
Thread.sleep(mill);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.project_21"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.project_21.Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.project_21.Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.project_21.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/android2"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".Main" >
<TextView
android:id="#+id/startsInfo"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:gravity="center"
android:text="#string/welcome"
android:textSize="30sp" />
<TextView
android:id="#+id/countDown"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/countDown"
android:textSize="45sp" />
<Button
android:id="#+id/appStartButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/appStartButton"
android:textSize="35sp" />
</LinearLayout>
ERROR LOG
The error message states that you are making a call to system services, before they are available. This is because you are calling them in the onCreate() method. Move the calls you are making in your Menu.java class (not included here, so can't tell you exactly which calls you are making) to another lifecycle method - onCreateView() is probably best for an Activity (onAttach() is a good one for Fragments).

Categories