Adding a Splash Activity

Discussion in 'Tutorials' started by Vas, Sep 3, 2013.

  1. Friendlyspeaking Active Member

    Member Since:
    Oct 12, 2012
    Message Count:
    86
    Likes Received:
    27
    Trophy Points:
    50
    Check the following codes if you want to make your text or background color transparent

    Code (text):
    For Normal Background Color:
    android:background="#000000" > black color
    android:background="#ffffff" > white color
     
    For Normal Text Color:
    android:textColor="#000000" > black color
    android:textColor="#ffffff" > white color
    Now if you want to add transparency to color, just add the two hex code in the starting

    Code (text):
    android:background="#80ffffff" >
     
    ^ This will make your white color 50% transparent.
     
    Hex Opacity/Transparent Values
     
    100% — FF
    95% — F2
    90% — E6
    85% — D9
    80% — CC
    75% — BF
    70% — B3
    65% — A6
    60% — 99
    55% — 8C
    50% — 80
    45% — 73
    40% — 66
    35% — 59
    30% — 4D
    25% — 40
    20% — 33
    15% — 26
    10% — 1A
    5% — 0D
    0% — 00
     
    Joshua if you have used background image and want to make it transparent then add the following code

    Code (text):

    android:alpha=".20"
    You can also make transparent image in Photoshop or any other photo editor software and then save it in .png format so you can use it as a transparent background image for Splash Screen.
    Vas, Maximus and Joshua like this.
  2. stollo770 LWC Major

    Member Since:
    Feb 2, 2012
    Message Count:
    236
    Likes Received:
    64
    Trophy Points:
    200
    I still cant get the splash screen to work. I've read every post in this thread and tried every suggestion. I'm at a wall. Screen shot below:

    The problem its saying for the first error is: "layout cannot be resolved or is not a field"
    The problem its saying for the second error is: "id cannot be resolved or is not a field"
    The problem its saying for the third error is: "id cannot be resolved or is not a field"

    Can someone please help me. I really want to ad a wonderful splash screen like your examples. If anyone figured out how to resolve these please tell me how. I've tried everything posted here, I'm desperate.

    Attached Files:

  3. Friendlyspeaking Active Member

    Member Since:
    Oct 12, 2012
    Message Count:
    86
    Likes Received:
    27
    Trophy Points:
    50
    ^ If you have designed wallpaper in 2.1 then you have to define activity in AndroidManifest.xml in the following way

    Code (text):
                   
            <activity
              android:name=".Splash"
              android:theme="@android:style/Theme.Black.NoTitleBar"
              android:screenOrientation="portrait"
              android:icon="@drawable/icon">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            </activity>

    For LWC 2.6 it is defined in the following way. The difference is only ".Splash" and "com.sbg.lwc.Splash"

    Code (text):

            <activity
              android:name="com.sbg.lwc.Splash"
              android:theme="@android:style/Theme.Black.NoTitleBar"
              android:screenOrientation="portrait"
              android:icon="@drawable/icon">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            </activity>
  4. Friendlyspeaking Active Member

    Member Since:
    Oct 12, 2012
    Message Count:
    86
    Likes Received:
    27
    Trophy Points:
    50
    You will have to import .R or define in your Splash.java in the following way.

    import yourpackagename.R;

    ex:
    import com.examplelwp.R;

    ^ just copy your package name and paste before R.
  5. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
    @stollo770 there is probably some sort of issue with your splash.xml. Look there :)
  6. stollo770 LWC Major

    Member Since:
    Feb 2, 2012
    Message Count:
    236
    Likes Received:
    64
    Trophy Points:
    200
    Thanks to @Friendlyspeaking I tracked the problem down to my manifest and corrected it. The updated manifest and the fixes that @fatos figured out resolved all my errors and I was able to compile the live wallpaper successfully in eclipse. However, I am still getting a black screen, followed by a crash when I go to open the splash screen on my phone. Any suggestions?
  7. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
    @stollo770 to understand a crash, use logcat.
  8. stollo770 LWC Major

    Member Since:
    Feb 2, 2012
    Message Count:
    236
    Likes Received:
    64
    Trophy Points:
    200
    I got it Vas, fatos send me copies of his working splash.java and splash.xml files and I got mine to work. Thanks again @fatos.
    Joshua likes this.
  9. fatos LWC Major

    Member Since:
    Apr 2, 2013
    Message Count:
    268
    Likes Received:
    73
    Trophy Points:
    200
  10. Joshua Seasoned Vet

    Member Since:
    Jul 12, 2013
    Message Count:
    116
    Likes Received:
    16
    Trophy Points:
    100

    Thanks a lot, I appreciate the help. If I wanted to make my settings menu transparent, how would I go about doing so?
  11. Friendlyspeaking Active Member

    Member Since:
    Oct 12, 2012
    Message Count:
    86
    Likes Received:
    27
    Trophy Points:
    50
    Find the below activity in your your Manifest.xml

    Code (text):
            <activity
                android:label="Settings"
                android:name="com.sbg.lwc.LiveWallpaperSettings"
                android:theme="@android:style/Theme"
                android:exported="true">
            </activity>
    Now just Replace this
    Code (text):
    android:theme="@android:style/Theme"
    to
    Code (text):
    android:theme="@android:style/Theme.WallpaperSettings"
    Joshua likes this.
  12. Joshua Seasoned Vet

    Member Since:
    Jul 12, 2013
    Message Count:
    116
    Likes Received:
    16
    Trophy Points:
    100
    And that's it? Awesome!

    You wouldn't know how to change the colour of the text in the live wallpaper settings menu also by any chance would you?


    Sent from my iPhone using Tapatalk - now Free
  13. Friendlyspeaking Active Member

    Member Since:
    Oct 12, 2012
    Message Count:
    86
    Likes Received:
    27
    Trophy Points:
    50
    Hello Joshua

    I researched on net and came to know that you will have to create your own style for customizing color. I have written a simple style for coloring text and tested it on my mobile, just follow the simple steps.

    1. Create a xml file in res > values > style.xml.

    2. Copy the following codes in your style.xml file.

    Code (text):
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
     
    <style name="SettingStyle" parent="android:Theme.WallpaperSettings">
     
      <item name="android:windowBackground">@android:drawable/screen_background_dark_transparent</item>
      <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
      <item name="android:windowIsTranslucent">true</item>
      <item name="android:textColorPrimary">#00ff00</item>
      <item name="android:textColorSecondary">#eeff00</item>
     
    </style>
     
    </resources>
    3. Now change the color code in the above code according to your need.

    4. Now open your manifest.xml and find the following activity.

    Code (text):
            <activity
                android:label="Settings"
                android:name="com.sbg.lwc.LiveWallpaperSettings"
                android:theme="@android:style/Theme"
                android:exported="true">
            </activity>
    5. Now replace the above code with the following code.

    Code (text):
            <activity
                android:label="Settings"
                android:name="com.sbg.lwc.LiveWallpaperSettings"
                android:theme="@style/SettingStyle"
                android:exported="true">
            </activity>
    6. Now compile your file and test your .apk on your mobile

    7. This should be the result :D

    [IMG]
    Vas and Joshua like this.
  14. Joshua Seasoned Vet

    Member Since:
    Jul 12, 2013
    Message Count:
    116
    Likes Received:
    16
    Trophy Points:
    100
    Wow. Phenomenal man. You're a great help. I couldn't thank you enough. You must have some pretty amazing themes. It's people like you that keep the live wallpaper creator community growing.
    Eraste and Friendlyspeaking like this.
  15. Friendlyspeaking Active Member

    Member Since:
    Oct 12, 2012
    Message Count:
    86
    Likes Received:
    27
    Trophy Points:
    50
    You are welcome, I just learnt and shared it nothing else :D
    Joshua likes this.
  16. Kazuki New Guy

    Member Since:
    Oct 31, 2013
    Message Count:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hey guys i just started to make some apps a few days ago and now i wanna implement Mobario in it so i did follow all the steps for it and all i have left to do is the splash screen stuff and i did follow this guide and i was able to fix some errors(i hope) and now i have 3 left and i really do not know what to do...can any of you help me out?Tell me step by step how to fix it .that be mighty kind of you =3..and btw im like a total noob at this(coding and stuff)....so here are the 3 errors on the Splash.java errors.jpg
  17. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
    Make sure you add that splash.xml file to res/layout
  18. Ramjet Active Member

    Member Since:
    Dec 2, 2013
    Message Count:
    67
    Likes Received:
    12
    Trophy Points:
    50
    Hi, my name's Paul. Late to the party as usual...

    Just bought the creator this evening after a few hours of playing with the demo, well good software!

    I've got a bit of experience of android dev'ing. I love splashscreens, love 'em, but I always feel that they're an extra hoop for always impatient android users to jump through. This is an alternative method that some might like to try...

    Adding a 'button' to the preferences screen to open the wallpaper picker intent. And making the preferences screen accessible directly from the apps tray.

    A few steps, but it's dead easy..

    androidmanifest.xml:

    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

    make the settings screen the launcher activity and change it's label to the app name:


    <activity
    android:label="@string/appName"
    android:name="com.sbg.lwc.LiveWallpaperSettings"
    android:theme="@android:style/Theme"
    android:exported="true">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

    lwp_settings.xml:

    Put this wherever you want the 'button' to be (it's not really a button). Preferences are like a linear layout, so wherever you put the code is were it'll be.

    <Preference
    android:title="Set Wallpaper!"
    android:key="button"
    android:summary="Look for Orange Flourish"/>

    So you could put it here for example:

    <Preference
    android:title="This is a free version"
    android:summary="Get the full version to enable settings such as item speed, direction and hit counters"
    android:key="demo_tag" />

    <Preference
    android:title="Set Wallpaper!"
    android:key="button"
    android:summary="Look for Orange Flourish"/>

    <ListPreference
    android:title="Number of Items"
    android:key="numOfItemsMultiplier"
    android:summary="Increase or decrease the amount of items"
    android:entries="@array/numOfItemsNames"
    android:entryValues="@array/numOfItemsValues"
    android:defaultValue="100" />

    (I know, I know, I'm still on the tutorial example!)

    Then in LiveWallpaperSettings.java:

    Just add this to the onCreate method:

    Preference button = (Preference)findPreference("button");
    button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference arg0) {
    Intent intent = new Intent();
    intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
    startActivity(intent);
    return true;
    }
    });

    It could go after the method for getting the lwp_settings xml:

    addPreferencesFromResource(R.xml.lwp_settings);
    getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);

    Preference button = (Preference)findPreference("button");
    button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference arg0) {
    Intent intent = new Intent();
    intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
    startActivity(intent);
    return true;
    }
    });

    That's about it really, hope it helps someone.

    [IMG]

    [IMG]

    No problem to add airpush or leadbolt, bit trickier to add banners, would probably be easier to add them programatically rather than through xml?...

    Actually, I was thinking (not for gplay of course) that the airpush universal sdk EULA listener could be added, so if a user rejects the eula the settings screen closes, but if they accept the eula they access the settings but are committed to receiving push notifications and icon ads... Wouldn't expect good feedback though!

    Anyway, 2.30 am here, off to bed.
  19. Ramjet Active Member

    Member Since:
    Dec 2, 2013
    Message Count:
    67
    Likes Received:
    12
    Trophy Points:
    50
    Turns out it's easy enough to add an airpush banner..

    Follow their documentation to add the mraid xml etc, then,

    create an xml file and dump it in the layout folder. I've called my xml file "ap_banner.xml"

    put their xml banner code in it, adjust layout to suit:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.xxxx.xxxxxxxx.AdView //airpush package name
    xmlns:ap="http://schemas.android.com/apk/res-auto"
    android:id="@+id/myAdView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ap:animation="fade"
    ap:banner_type="inappad"
    ap:placementType="inline"
    ap:test_mode="false"
    ap:canShowMR="true" />

    </RelativeLayout>

    In lwp_settings.xml add:

    <Preference
    android:layout="@layout/ap_banner"/>

    wherever you want it to go. I've added it top and bottom as it scrolls off screen:

    [IMG]

    [IMG]
    Vas likes this.
  20. wladca Active Member

    Member Since:
    Mar 20, 2013
    Message Count:
    50
    Likes Received:
    4
    Trophy Points:
    50
    Can you post these working files ?? Or someone ?

    Anyway this is my errors :

    [IMG]

Share This Page