Hi all,
I am trying to get map in android Emulator, But I have error message when i run the application.How to rectify this error?
My Code:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.googlemapsandroid"
android:versionCode="1"
android:versionName="1.0">
<uses-library android:name="com.google.android.maps.map" />
<application android:icon="@drawable/worldmap" android:label="@string/app_name">
<activity android:name=".GoogelMapsAndroid"
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>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0ubDx0zU6vaeSSZoV0oyPB4zi7y8T2hKSZfAyZw"
/>
</RelativeLayout>
GoogleMapsAndroid.java
package com.android.googlemapsandroid;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class GoogleMapsAndroid extends MapActivity
{
MapView mapview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapview=(MapView)findViewById(R.id.mapview);
mapview.setSatellite(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
I have error message:
java lang Runtime Exception Unable to instantiate ComponentInfo{com.android.googlemapsandroid/com.android.googlemapsandroid.MapsActivity}java.lang.RuntimeException: stub
Do you use Google APIs target in an emulator?
No. How to use Google api.
dineshsubramanian said:
No. How to use Google api.
Click to expand...
Click to collapse
This is what I mean:
http://img40.imageshack.us/f/screenshotcreatenewandr.png/
Thanks for your reply.
I will try in Google Api.
Now i ran in google api. but i have error message
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.googlemapdemo/com.googledemo.GoogleMapDemo}: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.android.maps.MapView.
I am new to SW development with Android.
Trying to have a MapView object in my display. Code is straightforward below. But for some reason when i launch the application i do not see any map but rather the grey grid.
I have looked at many posts on the internet and i understand that it is either an INTERNET permission (which is included in my coe) or a wrong apiKey. I have gone through the apiKey several time.
Am not sure what can be wrong. Any help would be great. Thanks, Lebnen.
-----------------------------------------------
Manifest.xml
-----------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.testmap"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".TestMapActivity"
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>
-----------------------------------------------
main.xml
-----------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:enabled="true"
android:apiKey="0SA_n7tIj-klgGxARuFJgEos8FBGtEshpgmfogA"
/>
</LinearLayout>
-----------------------------------------------
testMapActivity.java
-----------------------------------------------
package com.test.testmap;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.LinearLayout;
import com.google.android.maps.MapView;
import com.google.android.maps.MapController;
import com.google.android.maps.MapActivity;
import com.google.android.maps.GeoPoint;
public class TestMapActivity extends MapActivity {
private MapView mapView;
LinearLayout linearLayout;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mapView = (MapView) this.findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
}
@Override
public boolean isRouteDisplayed() { return false; }
}
Dont see your manifest. Is it a dev map key ? Is the application debuggable in the manifest ?
Sent from my Nexus One using XDA App
1. What do you mean by dev map key? Am using the debug.keystory MD5 hash that I feed into the google page http://code.google.com/android/add-ons/google-apis/maps-api-signup.html to get the apiKey.
2. The application is debbugable in the manifest.
Ok i see your files on computer now (not on android application on my nexus one)
replace com.google.android.maps.MapView by com.test.testmap.testMapActivity
If I replace it in main.xml the application crashes; in the manifest it does not compile
Help!
the:
<uses-permission android:name="android.permission.INTERNET" />
you have to put on <manifest>, not on <application>
like
<manifest ...>
<application ...>
<uses-library android:name="com.google.android.maps" />
.
.
.
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Other thing that I'm not totally right if it's correct:
I don't know if this is correct, but for me, only worked when I create a new Android Project with Target on Google API's. Didn't work with Android 2.2 + map.jar.
Did you create with Android X.X or Google API ?
I have tried to put the INTERNET permission inside and outside the application. It does not make a difference.
I am building a Google API application.
It worked.
Weird. I had to add
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
in <manifest> outside of <application> and did it through the "Permissions" tab in Eclipse.
Thanks.
Interesting, because I thought that the "ACCESS_FINE_LOCAT ION" is used only when you try to use something with location, such as get location, distance between locations, etc..., I thought that it's not necessary when you only want to show the map
Good to know, thank you
Hi people, I am newbie , trying to learn android developing.
So i was making this app. which uses the camera client android clicks a picture and then sets it as wallpaper, as per the user's request.
But when i try to install it on my phone (Samsung Galaxy y duos ). It says application not installed. I am not able to understand why. I have also added the permissions on the Android manifest. Please do help me out. I will be attaching the xml for the camera app and its Class.
THE JAVA CLASS...
Code:
package com.example.done;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
public class Camera extends Activity implements View.OnClickListener {
Button camera;
ImageButton done;
ImageView wallpaper;
int cameraData = 0;
Intent i;
Bitmap pic;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.photo);
intial();
camera.setOnClickListener(this);
done.setOnClickListener(this);
InputStream is = getResources().openRawResource(R.drawable.abc);
pic= BitmapFactory.decodeStream(is);
int cameraData = 0;
Intent i;
}
private void intial() {
// TODO Auto-generated method stub
camera = (Button) findViewById(R.id.camera);
done = (ImageButton) findViewById(R.id.imgTile);
wallpaper = (ImageView) findViewById(R.id.imagButt);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.camera:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
break;
case R.id.imagButt:
try {
getApplicationContext().setWallpaper(pic);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle e = i.getExtras();
pic = (Bitmap) e.get("data");
wallpaper.setImageBitmap(pic);
}
}
}[/CODE]
the Xml file (photo.xml)
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="xda wont allow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgTile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/abc"
android:layout_gravity="center" />
<ImageButton
android:id="@+id/imagButt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button" />
</LinearLayout>
ThankYou in advance
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Manifest
Androguide.fr said:
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Click to expand...
Click to collapse
Yeah i am on eclipse.
And yup I am using a signed APK.
Actually, if i hit run. It would start up my emulator(It is installng on that perfectly).
But i have not connected my emulator to the webcam, so it would forceClose.
I have also set my emulator to Qvga.
And yup, the i have attached the manifest too.:good::good:
Manifest
Androguide.fr said:
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Click to expand...
Click to collapse
Yeah i am on eclipse.
And yup I am using a signed APK.
Actually, if i hit run. It would start up my emulator(It is installng on that perfectly).
But i have not connected my emulator to the webcam, so it would forceClose.
I have also set my emulator to Qvga.
And yup, the i have attached the manifest too.:good::good:
Actually the app i am developing, includes a menu which includes some other apps. Everything other app was working fine, until i added the camera app. . If you want the classes of the other apps, I can provide you that. But please help me. Thanks
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.done"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<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="com.example.done.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.done.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.done.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Password"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Email"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Camera"
android:label="cameraApp"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
Add this permission to your manifest :
Code:
<uses-permission android:name="android.permission.CAMERA"/>
What version of Android is your device running ? You might wanna change this line
Code:
android:targetSdkVersion="8"
to :
Code:
android:targetSdkVersion="17"
if you want your app to support devices running ics & jellybean and/or be able to use the latest APIs (download the android 4.2.2 sdk platform if eclipse throws an error)
EDIT : you also have a whitespace in this line, remove it :
Code:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CA [COLOR="DarkRed"]here [/COLOR]PTURE
It would be helpful if you paste in here the output of the console. It has nothing to do with the java code since it is being installed in the emulator.
Still not working
Androguide.fr said:
Add this permission to your manifest :
Code:
<uses-permission android:name="android.permission.CAMERA"/>
What version of Android is your device running ? You might wanna change this line
Code:
android:targetSdkVersion="8"
to :
Code:
android:targetSdkVersion="17"
if you want your app to support devices running ics & jellybean and/or be able to use the latest APIs (download the android 4.2.2 sdk platform if eclipse throws an error)
EDIT : you also have a whitespace in this line, remove it :
Code:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CA [COLOR="DarkRed"]here [/COLOR]PTURE
Click to expand...
Click to collapse
As you said, i made all the changes. (Includind premissions etc.)
But it is not working.
When i run it on my emulator, it is getting installed. But when i run it on my phone.. It says app not installed.
Also I am attchiing the console output.
[2013-04-16 12:49:11 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 12:49:12 - done] New emulator found: emulator-5554
[2013-04-16 12:49:12 - done] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 12:50:09 - done] HOME is up on device 'emulator-5554'
[2013-04-16 12:50:09 - done] Uploading done.apk onto device 'emulator-5554'
[2013-04-16 12:50:35 - done] Installing done.apk...
[2013-04-16 12:50:57 - done] Success!
[2013-04-16 12:50:57 - done] Starting activity com.example.done.Splash on device emulator-5554
[2013-04-16 12:51:00 - done] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.done/.Splash }
hiphop12ism said:
As you said, i made all the changes. (Includind premissions etc.)
But it is not working.
When i run it on my emulator, it is getting installed. But when i run it on my phone.. It says app not installed.
Also I am attchiing the console output.
[2013-04-16 12:49:11 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 12:49:12 - done] New emulator found: emulator-5554
[2013-04-16 12:49:12 - done] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 12:50:09 - done] HOME is up on device 'emulator-5554'
[2013-04-16 12:50:09 - done] Uploading done.apk onto device 'emulator-5554'
[2013-04-16 12:50:35 - done] Installing done.apk...
[2013-04-16 12:50:57 - done] Success!
[2013-04-16 12:50:57 - done] Starting activity com.example.done.Splash on device emulator-5554
[2013-04-16 12:51:00 - done] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.done/.Splash }
Click to expand...
Click to collapse
You're giving us the output for the emulator here... We need to see the output for when you install it on an actual device as it's where your problem is.
I attached a screenshot.
I hope that helps.
So as i told you, everything was working fine. Until i added the camera app. But for experiment's sake, i deleted the app's xml, java and the activity from the manifest. But still the same result.
As i.told you, the camera app is a sub app in my phone..
The whole app contains some more app. But even then its not working:thumbup::thumbup:
Sent from my GT-S6102 using xda app-developers app
Problem Solved
Hey fellas.
I thought that changing the phone, would solve the problem,
So i used samsung s2 instead of samasing galaxy y duos.
And the app worked....
But i am not able to determine the reason.
Why don't you post the output of the console? You have been asked several times :good:
You will not find anything in the console.
As eclipse installes the apk in my emulator. In the emulator, it installs perfectly. So everything in the console is positve. Anyways i have already attached the console output in the previous page. And if you need the logcat. I will provide you.
Anyways, a great thanks for your concern
--------+---------+-----------+-------------
Sent from my GT-S6102 using xda app-developers app
Could you provide us your android manifest?
Maybe you need to set a lower minSdkVersion. (Although it says "Parsing error" on my Samsung Galaxy Ace if there is a wrong minSdkVersion)
I have copied the manifest in the previous page. I have tried putting minsdk on qvga adpi.
But it didnt work..
Sent from my GT-S6102 using xda app-developers app
hiphop12ism said:
I have copied the manifest in the previous page. I have tried putting minsdk on qvga adpi.
But it didnt work..
Sent from my GT-S6102 using xda app-developers app
Click to expand...
Click to collapse
Ah. Ok. Thanks.
The minSdkVersion is the minimum Android version which has to be installed on the device.
8 is the code for Android 2.2.
Which Android version is running on your device? Maybe you will need to set it to a lower value.
i have 2.3.6
Sent from my GT-S6102 using xda app-developers app
I'm implementing app indexing and I think I'm missing something, but I don't know what.
Following the guide I added my intent-filters to the app and implemented what's needed in my activity.
my application's package is com.towers.mypackage and the associated website (where I didn't put the link rel meta-tag yet, since I'm just testing) is www.mypackage.com
I saw the following intent-filter example in the guide
HTML:
<activity
android:name="com.example.android.PetstoreActivity"
android:label="@string/title_petstore">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.examplepetstore.com" />
</intent-filter>
</activity>
so I wrote mine in this way:
HTML:
<activity
android:name=".ActivityForAppIndexing"
android:label="@string/title_activity"
android:screenOrientation="portrait" >
<intent-filter android:label="@string/app_name">
<data android:scheme="android-app"
android:host="com.package.myappname" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.mywebsite.com" />
<data android:scheme="https"
android:host="www.mywebsite.com" />
</intent-filter>
</activity>
Also, I wrote a content provider in order to parse the URI
HTML:
<provider
android:name=".contentproviders.HotelDetailsContentProvider"
android:authorities="com.towers.mypackage" >
</provider>
which should map the URIs as follows:
Code:
private static final String BASE_PATH = "https";
private static final String AUTHORITY = "com.towers.mypackage";
public static final Uri CONTENT_URI = Uri.parse("android-app://" + AUTHORITY
+ "/" + BASE_PATH);
I'm testing the implementation via command line using the following adb command:
Code:
adb shell am start -a android.intent.action.VIEW -d "https://mypackage.com?hotel_id=135738" com.towers.mypackage
and IT WORKS. The app gets automatically opened with the right activity and the right parameters. When the app starts the onNewIntent method gets called:
Code:
protected void onNewIntent(Intent intent) {
String action = intent.getAction();
String data = intent.getDataString();
if (Intent.ACTION_VIEW.equals(action) && data != null) {
String recipeId = data.substring(data.lastIndexOf("/") + 1);
Uri contentUri = HotelDetailsContentProvider.CONTENT_URI.buildUpon()
.appendPath(recipeId).build();
bundle = new Bundle();
bundle.putString("pictureUrl", "");
//showRecipe(contentUri);
}
}
(I got it of course from the examples, that's why it talks about recipes)
But I wonder: what should I do? Get data from the intent with a
Code:
getIntent().getData().getQuery()
or use the ContentProvider and get them from the URI?
Also, I'd like to test with the Google Search Console and the "View as google" funcionality if everything is okay. I uploaded my APK and saw an URI is requested.
Now, in the "testing your app" section of the documentation I saw that the links like http://mypackage.com?hotel_id=135738 are referred as "deep links" while those like android-app://com.towers.mypackage/https/mypackage.com?hotel_id=135738 are referred as "URI". Am I right?
The "View as google" funcionality asks for a URI but I don't know how to create one. Also, I wonder how this URI is passed to the app and I'm pretty sure I'm getting very confused about this all URI/deepLink thing, and can't find relief in the documentation.
Where and when should I use the URI? Where and when should I use the deepLink? I guess that since I'm going to put the link rel=URI in my webpages then the app will be called in the app indexing with the URI and not with the URL of the page. But if it's so... why is the adb shell am start -a android.intent.action.VIEW -d command used for testing with the URL and not the URI? Should my app be able to get and handle URIs or URLs? And how?
I thought I had understood something about app indexing, but today I'm starting to think I got it all wrong since I started. That's why I ask you for help in answering the questions above, and possibly sheding a light on all this URL/URI/intent-filter/ContentProvider mess.
I already talked about this on Stackoverflow and got two answers, plus a lot of comments. But I wasn't able to get anything from that, App indexing remains a mysterious monster to me :-/
Did anyone of you manage to make this kind of things work? And how?
Thank you everybody, really.
Hello,
I create that thread to present you a tutorial learning you how to create a Splash Screen on Android by following the right way. Note that you can also discover this tutorial in video on Youtube :
Create a Splash Screen on Android : the Right Way !
At a certain moment in the past, Google advised against using a Splash Screen on Android Applications. It was useless. Then, when they have published the Material Design Specifications, some of us have seen that the Splash Screen was now a pattern known as Launch Screen. Ideal to display your brand logo during cold start of applications. So, what’s the difference between the bad Splash Screen and the good Splash Screen ?
The difference is just the way you implement if. Previously, developers implemented the Splash Screen by displaying their brand logo on the screen during a certain time. The right way to implement a Launch Screen is now just to display your brand logo the time the application starts and no more.
To create a correct Splash Screen, you need to create a background that will display your brand logo to the screen. For this, you must create an XML file in the res/drawable folder :
Code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorPrimary" />
<item>
<bitmap android:src="@drawable/logo"
android:gravity="center" />
</item>
</layer-list>
Next step is to create a dedicated theme for your Splash Activity. For this, you must inherit from the Theme.AppCompat.NoActionBar theme :
Code:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background</item>
</style>
</resources>
Note that your Splash Theme has just to define the android:windowBackground item and set up the background created previously.
Now, you can create your SplashActivity :
Code:
package com.ssaurel.splashscreen;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
/**
* Created by ssaurel on 02/12/2016.
*/
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
No need to define a content view for the SplashActivity because you are going to apply the SplashTheme on it. So, you have just to launch the MainActivity of your Android Application and then finish the SplashActivity by calling the finish() method.
Don’t forget to define your SplashActivity in the Android Manifest and apply the SplashTheme on it :
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ssaurel.splashscreen">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SplashActivity" android:theme="@style/SplashTheme">
<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>
Then, you can write the code of your Android Application in your MainActivity as you want. You can try the application by seeing the demo in the previous video. Now, you could make Splash Screen on Android by following the right way !
Don't hesitate to give it a try and give me your feedbacks !
Thanks.
Sylvain