• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help with splash screen

go6o78

Lurker
Code:
package com.customlivewallpapercreator.live_wallpaper.amin;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class SplashScreen extends Activity {

   // Splash screen timer
   private static int SPLASH_TIME_OUT = 3000;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_splash); - РЕДА С ГРЕШКАТА

       new Handler().postDelayed(new Runnable() {

           /*
            * Showing splash screen with a timer. This will be useful when you
            * want to show case your app logo / company
            */

           @Override
           public void run() {
               // This method will be executed once the timer is over
               // Start your app main activity
               Intent i = new Intent(SplashScreen.this, MainActivity.class);
               startActivity(i);

               // close this activity
               finish();
           }
       }, SPLASH_TIME_OUT);
   }

}
Hello
i try to add splash screen in my project and insert some admob ad code
but i have some error
here is my project
https://drive.google.com/open?id=0B2u6yCWB2rETMjJhNXpOSEswNXc
For splash screen i try this code
https://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/
and few more but all of them give me some error
this source
https://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/
give me this errors .
Can somebody help me
Error:(16, 32) error: cannot find symbol variable activity_splash
Error:Execution failed for task ':livewallpaper:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

package com.customlivewallpapercreator.live_wallpaper.amin;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class SplashScreen extends Activity {

// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash); **- --- the error**

new Handler().postDelayed(new Runnable() {

/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/

@override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashScreen.this, MainActivity.class);
startActivity(i);

// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}

}
 
Looks like you haven't defined a layout with id "activity_splash".
You need to create and build a corresponding layout for your Activity, using XML.
 
i have activity_splash_screen.xml
try this also
setContentView(R.layout.activity_splash_screen);
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
      tools:context=".MainActivity">


    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
    </com.google.android.gms.ads.AdView>

</RelativeLayout>
 
and now this code is working :)
setContentView(R.layout.activity_splash_screen);
before give me error :)

i can make a build but app is crashing
 
Last edited:
yes but app is crashing :) on my phone
in debug give me this
Error running SplashScreen: The activity must be exported or contain an intent-filter
 
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.customlivewallpapercreator.live_wallpaper.amin"
    android:versionCode="100"
    android:versionName="1.00">

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19" />

    <uses-feature android:name="android.software.live_wallpaper" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/appName"
        android:largeHeap="true">

        <!-- Wallpaper Service -->
        <service
            android:name=".CustomWallpaper"
            android:label="@string/appName"
            android:permission="android.permission.BIND_WALLPAPER">
            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" />
            </intent-filter>

            <meta-data
                android:name="android.service.wallpaper"
                android:resource="@xml/wallpaper" />
        </service>
        <!-- Splash screen -->
        <activity
            android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
                       android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Black.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity" />
        <activity android:name=".SplashScreen"></activity>
        <activity
            android:name="info.androidhive.androidsplashscreentimer.MainActivity">
        </activity>

              <!-- Splash screen -->
        <activity
            android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Black.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Main activity -->
        <activity
            android:name="info.androidhive.androidsplashscreentimer.MainActivity">
        </activity>
    </application>

</manifest>
 
I think you modified a project and forgot to change the package name in the Manifest. In the code, your Activity SplashScreen is declared in package

Code:
package com.customlivewallpapercreator.live_wallpaper.amin;

But your Manifest refers to a different package

Code:
android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
 
i want to add the splash screen before my app
first i made the project and its working ok. After i add splash screen the project crash
Now i saw the Manifest has some changes.
Can you tell me what exactly i must edit
I'm not a programer :)
 
Back
Top Bottom