Assistance Android Manifest Please - java

I need a hand with the Android Manifest file.
I have 4 java files called: MainActivity, Splash, TextPlay and Menu. I want the Splash file to be displayed first. (I have it set for 5 seconds)
I then want the Menu to be displayed(I have the rest of the files displayed on Menu page.)
The app also wont debug on the emulator and im guessing its the manifests fault.
Can someone help me achieve this, Thanks!!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intigerdev.numberapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.intigerdev.numberapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MENU" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TextPlay"
android:label="#string/app_name" >
</activity>
</application>
</manifest>

You will have to move between activities on your own. The manifest doesn't do that for you.. if you want your app to start on the Splash screen use this manifest instead:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intigerdev.numberapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
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=".Menu"
android:label="#string/app_name"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name"/>
<activity
android:name=".TextPlay"
android:label="#string/app_name"/>
</application>
</manifest>
OnCreate of the Splash activity (stackoverflow.com/a/6489385/736496):
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
finish();
Intent intent = new Intent(Splash.this, Menu.class);
startActivity(intent);
}
}, 5000);
}

Related

How to change first activity in Android Studio?

I want to change my first activity, first I have activity named MainActivity. And I add new activity named ActivityFirst. Surely I have to change AndroidManifest.xml. Previously I have androidManifest like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edmt.dev.androidsimsimi">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And after I add my new activity, also I change my androidManifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edmt.dev.androidsimsimi">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".ActivityFirst">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I'm confused where I put the MainActivity after I add ActivityFirst. This my ActivityFirst.java:
public class ActivityFirst extends AppCompatActivity {
private Button mulai;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
mulai = (Button) findViewById(R.id.mulai);
mulai.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(ActivityFirst.this, MainActivity.class);
startActivity(intent);
}
});
}
}
You need <activity> tags for each Activity in your app's manifest file as mentioned here in the docs:
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.
So in your case, it'd be like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edmt.dev.androidsimsimi">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".ActivityFirst">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
</application>
</manifest>
In Android, The first Activity to show when a app is launched is tagged LAUNCHER in your manifest file.
All you need do to change the Launcher Activity is to add an intent-filter tag inside the activity tag.
So if your activity tag was self closing, you change it and add intent filter tag inside the tag.
Here is an illustration.
<activity android:name=".MainActivity" />
<activity android:name=".ActivityFirst">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The above code in your Manifest will make ActivityFirst the launcher activity,
while the below code will make MainActivity the launcher activity.
<activity android:name=".ActivityFirst" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I hope this helps.

The Icon App dosen't appear in my activities

when I update my SDK the icon app doesn't appear in the activities I tried all the solution on the internet but nothing happened .. I tried also to put " android:icon" in each activities nothing change also made a custom actionbar also nothing change .. please any help?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=""
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
"
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme" >
<activity
android:name=".Main"
android:label="#string/app_name"
android:theme="#style/NoActionBarTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Option"
android:label="#string/title_activity_option" >
</activity>
<activity
android:name=".CustomList"
android:label="#string/title_activity_custom_list" >
</activity>
<activity
android:name=".Social"
android:label="#string/title_activity_social" >
</activity>
<activity
android:name=".About"
android:label="#string/title_activity_about" >
</activity>
<activity
android:name=".ActionBar"
android:label="#string/title_activity_action_bar" >
</activity>
</application>
</manifest>

Android Button Click Crashes App

Intent intent = new Intent();
intent.setClass(MainActivity.this, Line.class);
startActivity(intent);
My cellphone alert "Sorry,The program has stopped working".
Why?
This is the error. http://www.mgiga.com.tw:8080/mo/01.jsp
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="com.sample.activity.MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Best if you could share the error you get in your logcat
Intent intent = new Intent(MainActivity.this, Line.class);
startActivity(intent);
Because your program can crash because of a lot of reasons.
Line is an Activity you haven't declare it inside manifest. Thats why you get ActivityNotFoundException.
Edit :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="com.sample.activity.MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.dragimagedemo.Line" >
</activity>
</application>
May be there is some problem in your second activity("Line.class") not in button click. Make another demo activity with "hello world" & check that still your app crashes or not. Example: if your demo activity named "DemoActivity" Then write code
Intent intent = new Intent(MainActivity.this, DemoActivity.class);
startActivity(intent);
If you give Logcat error then it is better understandable for us.
Edited: add activity in your manifest.xml
<activity
android:name="YourPackageName.Line"
android:label="#string/app_name">
Try this way,hope this will help you to solve your problem.
Intent intent = new Intent();
intent.setClass(MainActivity.this, "YourPackageName.Line");
startActivity(intent);
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Line"/>
</application>
</manifest>

Why doesn't my Manifest file declare a java package?

I can't seem to find an answer to this, so I guess I'll ask it myself. No matter what I try, Eclipse claims that my AndroidManifest.xml file doesn't declare a java package. Here's my code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:name="hess.jacob.spindoctor"
android:versionCode="19"
android:versionName="4.4" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="hess.jacob.spindoctor.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>
Maybe someone can find the problem, and suggest a solution. I'd gladly appreciate it.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hess.jacob.spindoctor"
android:versionCode="19"
android:versionName="4.4" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="hess.jacob.spindoctor.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>
Yes , Package name is missing
You have set the name , not the package.
android:name="hess.jacob.spindoctor"
It should be
package="hess.jacob.spindoctor"

Launcher activity not starting first

The title explains it pretty much, here is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.craym.vulcrum.firstgametnb"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
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=".StartingPoint"
android:label="#string/app_name" >
<intent-filter>
<action android:name="eu.craym.vulcrum.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Yet whenever I run this application, the StartingPoint classed is called first:
[2013-03-09 18:36:40 - FirstGameTNB] Starting activity eu.craym.vulcrum.firstgametnb.StartingPoint on device emulator-5554
Why is this happening? I thought the MAIN and LAUNCHER were supposed to make it so the Splash class gets called first, but this never happens. Note that when I delete the StartingPoint activity, it goes to Splash.
You're right. You may try a clean on your project.
android.intent.action.MAIN: Start as a main entry point, does not
expect to receive data.
Source

Categories