I am just starting with android and trying to alter my android manifext .xml file such that a particular activity is launched first. My code is as follows:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".CrimeListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".CrimeActivity">
</activity>
</application>
I have a CrimeListActivity java class which simply should display an empty activity. However, it continues to default to displaying the activity that was specified in the manifest originally. ( In this case, .CrimeActivity.
It's hard to be more specific without posting too much code so I'm hoping someone could give me a couple pointers on where to start poking around when issues like this arise.
Thanks!
Related
When first starting a simple app, usually the title of the app is on the top of the activity. However, for me, it says com.example.inventory.MainActivity and then when I switch activities to another one, it'll say com.example.inventory.AddProduct
This is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.inventory">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".ProductList"></activity>
<activity android:name=".AddProduct" />
<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>
I'm a beginner so sorry if I forgot to include any other important file.
You need to add a label for your activity like this:
<activity android:name=".ProductList"
android:label = "Product Screen"></activity>
Replace Product Screen with the Title of your choice.
Do the same for all the other activities in the Manifest.xml
My home page needs to show two buttons: login & register. The page Login Activity with both buttons should appear first, but only the register screen comes up.
I am very new to coding. So, please be nice :( I've been stuck on this for days.
Below is the AndroidManifest.xml. Can anyone spot what I am doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.thrd">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity"></activity>
<activity android:name=".UserAreaActivity"></activity>
</application>
</manifest>
You manifest file is ok. Probably you have some logical errors in your code. In LoginActivity. So it launches RegisterActivity (probably in onCreate), instead of showing itself.
I have been trying to download some stuff from the internet in my app, but in the second activity. I have added the permission request, and it works in my first activity, but not in the second one? is there anything i'm forgetting? otherwise, why would i possibly be getting a permission error?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ruslan.seriesstuff">
<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"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".Main2Activity">
</activity>
</application>
The problem occurred because of the newer version of android, in my case 6.0. I solved this problem by doing the following. Long press on the app icon in your phone, drag it to the appeared icon of app info. There go to the permissions of the app and make sure you have actually provided the permission to the internet. That's it!
I'd like to solve a "too much waiting" problem. Hi to everybody :)
The case is that i've an application with a main menu that has 2 buttons. I'll paste the manifest here so you can see what I'm talking about.
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="razvitrance.administradorcontraseas.PantallaPrincipal"
android:label="#string/title_activity_pantalla_principal"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
<activity
android:name="razvitrance.administradorcontraseas.PantallaPrincipalAdministrar"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
<activity
android:name="razvitrance.administradorcontraseas.PantallaAyuda"
android:label="#string/title_activity_pantalla_ayuda"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
<activity
android:name="razvitrance.administradorcontraseas.PantallaAdministraroGenerar"
android:label="#string/title_activity_pantalla_administraro_generar"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
<activity
android:name="razvitrance.administradorcontraseas.PantallaPrincipalGenerar"
android:label="#string/title_activity_pantalla_principal_generar"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
<activity
android:name="razvitrance.administradorcontraseas.SplashScreen"
android:label="#string/title_activity_splash_screen"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
My main menu called .PantallaPrincipalAdministraroGenerar has 2 buttons and each of them call the new .PantallaPrincipalAdministrar and .PantallaPrincipalGenerar activities.
Well, my problem is that when I push the first of them, it takes no time to show the activite because it seems that that activity is already loaded, but when I push the second one the .PantallaPrincipalAdministrar takes too long until it appears on front and I do see on android studio's console how it is loading and creating all the files & allocating all the memory.
Is there any way I can preload all my activities in the boot of the app or while the splashscreen??
Thank you so much.
Luckily you cannot really. And you are most likely addressing problem in wrong place - if your activity takes too long to start check what you are doing in onCreate(), offload some tasks to background thrads, rework your ui, use Fragments, use lazy initialization etc, etc.
I am very new to android development with eclipse, and I encounter dozen of errors and problems. Here is the next one:
I am following an android tutorial given here in order to set up the action bar. In this tutorial is says to insert an activity as follows:
<activity android:theme="#style/Theme.AppCompat.Light" ... >
Can I just put this line into the xml manifest file?
<activity android:theme="#style/Theme.AppCompat.Light">
Or do I need to replace the '...' by something more useful?
Please read the docs: activity-element
The activity's name is required, so you would need to have:
<activity android:theme="#style/Theme.AppCompat.Light" android:name="MyActivity">
Other than that, you are not required to add any other attributes.
Although be sure to place the activity element within the proper place in your xml. It should be contained in your application block:
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light">
<activity android:name="MyActivity"
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>
Unless you really want your app to work under API levels under 3.0 then you have to add it like this.
android:theme="#style/Theme.AppCompat.Light"
Inside your already defined activity in your manifest (the one that has the intent filter and other declarations).
otherwise you dont have to add that at all.
This is one example.
<activity
android:name=".MainActivity"
android:theme="#style/Theme.AppCompat.Light"
android:screenOrientation="portrait"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and this is another
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme=#style/Theme.AppCompat.Light"" >
<activity android:name=".DetailActivity"
android:label="#string/app_name" >
</activity>
The second way you posted is just fine, be sure to close the activity tag so it looks like <activity android:theme="#style/Theme.AppCompat.Light"></activity>
Also, if you're using eclipse, it is easier to go into the AndroidManifest and under the Application tab scroll to the bottom where there's Application Nodes and then add your view from there. Eclipse will auto generate the correct code in the xml file.