2

when my application is installed for the first time by the user , i want to explain him what each activity does (like a quick tip) , it should look like the below picture

enter image description here

it should have the cancel button , and should not repeat after the first install,

I need suggestion or any useful links ,how to implement it, Any help is appreciated.

teekib
  • 2,821
  • 10
  • 39
  • 75
  • You can do this with Preferences Please refer http://developer.android.com/reference/android/preference/package-summary.html – Dixit Patel Jan 07 '13 at 06:09
  • what about starting an `Activity` *(with no animation)* for the quick tip? so you can start it from anywhere with different tips every time? – Adil Soomro Jan 07 '13 at 06:43
  • @AdilSoomro i have 5 screens and i need 5 quick tips whenever the user uses that feature for first time. – teekib Jan 07 '13 at 06:48

1 Answers1

1

You could use SharePreference to store the state whether or not user have viewed your instruction. Just add a boolean value named as 'instructionViewed' to SharePreference. Every time your application launched, check the value. If true, don't show instruction. If false, show instruction. When user click the cancel button, set the value to true.

SharePreference is a very easy-using class to help store some information.You could google how use it.

Hope this helpful.


    @Override
    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.testpage);

         //Check SharePreference
         boolean instructionViewed = checkInstrunctionState();

         //If the instruction is not viewed, show instruction.    
         if(!instructionViewed){
               RelativeLayout yourLayout = createYourOwnUi();
               FrameLayout contentView  = (FrameLayout)(getWindow().getDecorView().findViewById(android.R.id.content));
               FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT,MATCH_PARENT);
               contentView.addView(yourLayout, lp);
             }
        }
wayne_bai
  • 1,218
  • 4
  • 14
  • 23
  • Thank you..shared preference is perfect for this , iam confused about the UI, how can i get the exact same Ui as above pic. – teekib Jan 07 '13 at 06:37
  • yes how to implement that the semitransparent black background, that transparent background thing is on top of the activity. – teekib Jan 07 '13 at 06:50
  • So your issue is how to add it to top of the activity.From my code, you could see that I added your instruction layout to a FrameLayout(id is android.R.id.content), we call it ContentView. ContentView is the top FrameLayout contains your application(It is added by Android).When you added your instruction layout to contentview, the instruction layout will on the top and it will cover your application. – wayne_bai Jan 07 '13 at 06:55
  • Please read this thread. It explain more clearly.http://stackoverflow.com/questions/9979648/activity-addcontentviewview-viewgroup-addcontentviewview/9979929#9979929 – wayne_bai Jan 07 '13 at 06:57
  • Thanks for the link very useful..should i use createYourOwnUi(); in oncreate method of my activity? – teekib Jan 07 '13 at 07:05
  • I have updated the answer, please read. Yes, you should run createYourOwnUi in onCreate. – wayne_bai Jan 07 '13 at 07:14
  • what goes under createYourOwnUi(); and where should i add my content? – teekib Jan 07 '13 at 07:20
  • Hi, I don't think I need post more things. Now your issue is how to create UI dynamically and you could google much thing about this. – wayne_bai Jan 07 '13 at 07:33