Adding a Splash Activity

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

  1. sebastian Seasoned Vet

    Member Since:
    Feb 16, 2013
    Message Count:
    135
    Likes Received:
    36
    Trophy Points:
    100
    guys I was trying to insert a banner ad, then I put in the splash screen in a webview empty and splash.java this code:
    WebView wv = (WebView) findViewById (R.id.webView);
    wv.getSettings (). setJavaScriptEnabled (true);
    wv.setBackgroundColor (Color.Transparent);
    String.html = "<html> body style='margin:0; padding:0;'> <script type=text/javascript src=http://ad.leadboltads.net/show_app_ad.js?section_id=101211502> </ script> </ body> </ html> ";
    wv.loadData (html, "text / html", "utf-8");
    but I have these errors as you see in the image:
    this on this line of code:
    String.html = "<html> body style='margin:0; padding:0;'> <script type=text/javascript src=http://ad.leadboltads.net/show_app_ad.js?section_id=101211502> </ script> </ body> </ html> ";
    [IMG]
    and this on this line of code:
    wv.loadData (html, "text / html", "utf-8");
    [IMG]
    ps thi live wallpaper was created with live wallpaper 2.1
  2. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
    @Friendlyspeaking
    Well, the splash.xml looks fine. However, the class doesn't see the layout file and the IDs, which leads to me believe that splash.xml could be not in your resources. Post a screenshot of your project structure showing where you put splash.xml.

    @sebastian
    The splash appears when the user taps on the shortcut on the desktop/app drawer. When else do you want it to appear?
  3. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
    sebastian likes this.
  4. sebastian Seasoned Vet

    Member Since:
    Feb 16, 2013
    Message Count:
    135
    Likes Received:
    36
    Trophy Points:
    100
    thx vas now I am doing the screen shot but I don t understand what dot I should delete?? can you write me the correct way, please?
  5. sebastian Seasoned Vet

    Member Since:
    Feb 16, 2013
    Message Count:
    135
    Likes Received:
    36
    Trophy Points:
    100
    this is the structure:
    [IMG]
  6. Friendlyspeaking Active Member

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

    This is how the project structure looks like

    [IMG]
  7. fatos LWC Major

    Member Since:
    Apr 2, 2013
    Message Count:
    268
    Likes Received:
    73
    Trophy Points:
    200
    @Vas Somehow I did splash activity but when I press the icon it sends me to the live wallpaper picker. Is this the purpose of splash activity or splash should send me directly to the live wallpaper
    Joshua likes this.
  8. Joshua Seasoned Vet

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

    How'd you get it to work? My splash.java has errors

    Code (text):
    package com.sbg.lwc;
     
    import android.app.Activity;
    import android.app.WallpaperManager;
    import android.content.Intent;
    import android.graphics.Typeface;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageButton;
    import android.widget.TextView;
    import android.widget.Toast;
     
    public class Splash extends Activity{
           
        //Make a button that will take the user to the live wallpaper picker
        private Button lwpInstallBtn;
        //Make a simple textview for the title of your wallpaper that we can display in the splash activity
        private TextView title;
       
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //activities need to refer to an xml layout file, where you have laid out all of the participating components. xml layout files are stored in res/layout. ours is called splash.xml
            setContentView(R.layout.splash);
           
            //this is optional, but you can add your own fonts for your text components for more variety :) if you do, make sure you put it in your assets folder. in this example i have a fonts subfolder inside my assets.
            Typeface font = Typeface.createFromAsset(getAssets(), "fonts/SHOWG.TTF");
     
            //link the textview with the xml element using the ID that is given to it in the layout file
            title = (TextView) findViewById(R.id.title);
            //now you can apply the custom font, if you want to
            title.setTypeface(font);
           
            //now we link the button to the xml in similar fashion
            lwpInstallBtn = (Button) findViewById(R.id.installWallpaper);
            //apply the custom font again
            lwpInstallBtn.setTypeface(font);
            //add an on click listener to the button that will perform the action
            lwpInstallBtn.setOnClickListener(new ImageButton.OnClickListener() {
     
                public void onClick(View v) {
                    //this is where we customize the listener. basically we will outlay a set of instructions that will execute once the button is pressed.
                   
                    //first, we deal with accessing the wallpaper picker.
                    //we need to use an intent to tell the system that we want to access the live wallpaper picker. create a new intent with this next line
                    Intent intent = new Intent();
                    //tell the intent what to do.
                    intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
                    //send the intent through
                    startActivity(intent);
     
                   
                    //second, let's guide the user to select the wallpaper once they are in the wallpaper picker.
                    //we accomplish this by showing a toast message. it will briefly appear with our instructions. this is the line to get it done:
                    Toast.makeText(getApplicationContext(), "Select " + getString(R.string.application_name), Toast.LENGTH_SHORT).show();
                   
                    //now that we are done, close the splash activity since we don't need it anymore.
                    finish();
                }
            });
        }
       
        @Override
        protected void onResume() {
            super.onResume();
        }
       
        @Override
        protected void onStop() {
            super.onStop();
        }
     
        @Override
        protected void onDestroy() {
            super.onDestroy();
        }
    }
     
  9. TheShadow Active Member

    Member Since:
    Sep 12, 2012
    Message Count:
    73
    Likes Received:
    11
    Trophy Points:
    50
    @sebastian delete dot between string and html ie not String.html its String html a space must be added instead of dot.also don't forget to import R if you still get error.

    @fatos Splash will send you directly to live wallpaper picker.
  10. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
    @Joshua you gotta take a screenshot of the errors, or tell us what they say. Pasting the same code that I posted in my first post is not gonna tell us anything.

    @Friendlyspeaking Not sure what's wrong. You should not create anything in R as quickfix may suggest. You only need to import R, and that's it. I suggest doing Project>Clean.
  11. Friendlyspeaking Active Member

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

    R.java problem had been solved but now when I am clicking on the icon it shows the error "Unfortunately, Wallpapername has stopped." when I am running project in Eclipse it is showing the following error in LogCart.

    Code (text):
    09-10 15:52:46.543: D/dalvikvm(31477): GC_FOR_ALLOC freed 62K, 14% free 9391K/10883K, paused 22ms, total 22ms
    09-10 15:52:46.553: I/dalvikvm-heap(31477): Grow heap (frag case) to 14.392MB for 4147216-byte allocation
    09-10 15:52:46.588: D/dalvikvm(31477): GC_CONCURRENT freed <1K, 11% free 13440K/14983K, paused 12ms+2ms, total 38ms
    09-10 15:52:46.653: D/AndroidRuntime(31477): Shutting down VM
    09-10 15:52:46.653: W/dalvikvm(31477): threadid=1: thread exiting with uncaught exception (group=0x411542a0)
    09-10 15:52:46.658: E/AndroidRuntime(31477): FATAL EXCEPTION: main
    09-10 15:52:46.658: E/AndroidRuntime(31477): java.lang.RuntimeException: Unable to start activity ComponentInfo{hobbypoint.statue/com.sbg.lwc.Splash}: java.lang.RuntimeException: native typeface cannot be made
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.ActivityThread.access$700(ActivityThread.java:140)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.os.Handler.dispatchMessage(Handler.java:99)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.os.Looper.loop(Looper.java:137)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.ActivityThread.main(ActivityThread.java:4921)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at java.lang.reflect.Method.invokeNative(Native Method)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at java.lang.reflect.Method.invoke(Method.java:511)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at dalvik.system.NativeStart.main(Native Method)
    09-10 15:52:46.658: E/AndroidRuntime(31477): Caused by: java.lang.RuntimeException: native typeface cannot be made
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.graphics.Typeface.<init>(Typeface.java:306)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.graphics.Typeface.createFromAsset(Typeface.java:280)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at com.sbg.lwc.Splash.onCreate(Splash.java:30)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.Activity.performCreate(Activity.java:5206)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
    09-10 15:52:46.658: E/AndroidRuntime(31477):    ... 11 more
    09-10 15:52:46.663: I/Process(31477): Sending signal. PID: 31477 SIG: 9
     
  12. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
  13. Friendlyspeaking Active Member

    Member Since:
    Oct 12, 2012
    Message Count:
    86
    Likes Received:
    27
    Trophy Points:
    50
    Sorry I did not check the opened thread in detail, now it is working fine. Thank you very much :D
  14. sebastian Seasoned Vet

    Member Since:
    Feb 16, 2013
    Message Count:
    135
    Likes Received:
    36
    Trophy Points:
    100
    guys, I have done a bit of counts and I noticed something that maybe makes us a little hope ... Let me explain: I've noticed that for every app, every day I receive a number of clicks (click on the push notification) equal to new installations, this means that approximately notifications "work" on new installations.
    What I mean by that ... I mean that probably our revenure will likely remain the same, certainly will vary a little, but it will be roughly the same or ... well, I'm optimistic, or rather I think very often push notifications were synonymous with negative judgment (viruses, ad-aware, too many notifications, etc ...) in this way (with less intrusive advertising) probably our app will have better reviews and will be ranked higher in doing so increase the download ... . all this is just a hypothesis, but I hope it goes well .... what do you think?
    fatos likes this.
  15. fatos LWC Major

    Member Since:
    Apr 2, 2013
    Message Count:
    268
    Likes Received:
    73
    Trophy Points:
    200
    I really would like to maintain the same revenue but I have some doubts. Ad notifications was very annoying for my opinion and 95% of bad comments was because of notifications, but bad or not they gived us lot of revenue. It will be very hard to replace the profit of notifications but like Sebastian said lets hope we will have the same revenue with new Sdk.
    Joshua likes this.
  16. Joshua Seasoned Vet

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

    I read that leadbolt is soon to be releasing an awesome new sdk that should be as effective if not more effective than any other previous advertising means.
    fatos likes this.
  17. Joshua Seasoned Vet

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

    [IMG]
  18. fatos LWC Major

    Member Since:
    Apr 2, 2013
    Message Count:
    268
    Likes Received:
    73
    Trophy Points:
    200
    Joshua at + getString(R.string.application_name) hover the mouse on application_name and fix it whit action style
    And at splash.xml you have to delete @string/. Just let your live wallpaper name "Breaking Bad Live Wallpaper X" and save it.

    It worked for me
    Joshua likes this.
  19. Joshua Seasoned Vet

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

    Thanks man! I really appreciate it. Next step adding advertising :D
  20. Joshua Seasoned Vet

    Member Since:
    Jul 12, 2013
    Message Count:
    116
    Likes Received:
    16
    Trophy Points:
    100
    How about for the "wallpaper" text it's still giving me an error any ideas about that?

Share This Page