Instructions Page - android

I have just finished my first app in Android and now I want to build a small instructions page that will open when the application opens. Id like the user to be able to read a small set instructions and then just click a close button on the same screen to close the screen and begin using the application.
Should I do the with an alert box or is there a better way?
Thanks for the help.

I would use an Activity with the style set as Theme.Dialog you do this in the AndroidManifest.xml as follows...
<activity
android:name=".InstructionsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog">
...
</activity>
Use SharedPreferences to save a 'first run' boolean and check it in the onCreate(...) method of your MAIN/LAUNCHER Activity - if the boolean is true then set it to false then use startActivity(...) to start your InstructionsActivity dialog.

I would create a small activity with a TextView of your instructional information in a ScrollView with an anchored Close button at the bottom of the page.
Consider a layout similar to the Android first-setup layout:
You would use a centered Close button instead of a next button, but the idea would be the same. This is a very clean layout for longer messages in an application.

The AlertDialog is good for this however longer content may be better with a mobile optimized web page and don't forget to make the help available from other parts of the application.

Related

Android pop up list dialog

I want to add an dialog to my application. I want it to launch as soon as the first activity loads. But instead of having just a single message to display and having a 'yes' and 'no' button like this
I want it to display a list of message like this
If there is a tutorial that speaks on this subject I would be happy to look at it and also I would anybody by any chance know how to align these list with bulletins.
1 Create a custom dialog layout (XML file).
2 Attach the layout to Dialog.
3 Display the Dialog.
4 Done.
Tutorial here
If there is a tutorial that speaks on this subject I would be happy to look at it
Your best bet would be to start Here in the Docs. They show a great example of doing it with a Dialog.
Another option, if this can be the entire Activity since you want it to happen when if first starts, is to use a ListView for your Activity and use setChoiceMode() on it. You can find more about that in the Docs
With this second option, you can make the Activity appear as a Dialog by adding this line to your <activity> tag in the manifest.xml
android:theme="#android:style/Theme.Dialog"

Android Popup box similar to google license?

Hmm, looking at the way android popup it's text for the license with scroll, anyway to replicate it? Screen as below
For creating this pop up you need to do like this.
1) create an activity as like your displaying popup
2) add below section to the manifest file
<activity android:name=".popupActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog">//====> this makes the activity to display like pop up when call make to this activity
when you call this activity through intent its look like what you require..
Please use custom Dialogue box and add some scrollview and linear layout into it. Then put your actual text into it.
You can use this android popup library with your custom layout. Very simple to use with one line of code in your activity.
Pop.on(this).with()
.title(R.string.title) //you can skip if you don't need title
.layout(R.layout.license).show();

Android - Set image over home screen?

I want to set image over home screen when my app runs, like crack screen applications(Ex: https://play.google.com/store/apps/details?id=mk.g6.crackyourscreen&hl=en) to achieve something.
I beileve it has something to do with these permissions;
DISPLAY SYSTEM-LEVEL ALERTS
DISPLAY UNAUTHORIZED WINDOWS
But i cant find an example, tutorial or any article about it?
Thanks...
You should be able to do this by setting a transparent activity. For that matter, you can make your activity use the Translucent theme, like this (put this in the Manifest):
<activity android:theme="#android:style/Theme.Translucent.NoTitleBar">
(source)

Pass through touch events to app beneath

I'm working on an Android Activity which should not be full screen and thus uses Dialog theme. This can be achieved by adding
android:theme="#android:style/Theme.Dialog"
to the activity definition in Manifest file.
Visually that does what I expect. However, when the user interacts with the device in an area outside of this activity, the app in the background does not receive this input.
Is there a possibility to achieve this?
that is not possible with your solution as there is only one Activity possible to be active. You could try that with Fragments but I doubt that you could open your App and navigate the Homescreen / whatever in the meantime.

Layout puzzle development in Android

I am a newbie in Android.
I want to develop an application where I can change the screens based on button selected. Application might endup with 20+ screens with buttons or entry form. From 1 screen I got to change the screen to some other screen. I thought of FrameLayout where I can change the children.
I am not getting a way to start up. Like I created an Activity. My each screen should exceed which class so I can add it to the Layout ? How do I make my first screen visible on start up.
These all seem to be simple and silly questions, but really I can't get a starting point for the same. Any help is appreciative to help me achieve my goal.
UPDATED :
#Ghost, from your solution 1 more question arised in my mind. For screens where I only have to show buttons in specific format, I added a GridView and a ButtonAdapter with the help of this site.
If I add clickListener in ButtonAdapter only, then how can I pass parameters to setIntent(FooFooActivity.this....) ????? I have the Conext in ButtonAdapter - I can typecast it to FooFooActivity and can that work on. I can give ifs in ButtonAdapter in onclick() to make t go to proper screen. But the setIntent cna work the way I am saying or something like that. If it can work, then for many screens my single GridView and single ButtonAdapter class can do all the work.
NEW UPDATIONS ON Trials :
#Ghost, I tried and found that the above setIntent(FooFooActivity.this....) in ButtonAdapter doesnot work - as in ButtonAdapter it wont find scope for FooFooActivity.this.
In my FooFooActivity, I can't set onclikcListeners for buttons added via ButtonAdapter. I tried
with gridview.getChild(i), but just doesn't set in any way.
I also made another linearlayout xml (buttonspage.xml) with 6 buttons and a DataActivity that uses it. That works perfectly and on button click also shows FooFooActivity.
To use the same buttonspage.xml layout in multiple activities, I set the content of FooFooActivity as buttonspage and set its button click listeners. For 1 button I set to exit the application and for other button to show DataActivity.
So with this I got 2 activity, FooFoo that shows DataActivity/Exit & DataActivity that returns to FooFoo. Its a cycle that starts & ends up with FoofooActivity. If I click "Exit" at first, it quits. But If I click "Exit" after showing DataActivity, then it just doesn't quit and shows DataActivity only. Is it that I can't use same layout in multiple activity ?? Or may I be going wrong somewhere (I doubt so) ? Same buttonpage layout I got to use in 10-12 pages except with different text on button and events. So was thinking for Write Once Use Multiple Times. Also got to change button styles dynamically of all these pages buttons.
Thanks
As far as your first screen is concerned, it depends on the activity, and it runs directly when you run the project. For example, if you have your project named as FooFoo, then while compiling/building your android project, android itself names the first class as FooFooActivity (i.e., if you've allowed android to create an activity out of it). Of course, you can rename it then and there itself. So, once you compile your UI in the default main.xml file and come back to your java file FooFooActivity, there's a particular line inside the onCreate method. That line is setContentView(R.layout.main);This line sets the view of the contents present inside that main.xml file. When you run the program, and when emulator starts, the emulator presents the view of your main.xml if your project doesn't contain any compilation or runtime errors.
Now, coming to your 20+ layouts: You can have them all in your layout folder. Assign atleast one buttonin each screen that takes you to some screen say "XYZ" and let's assume that the class name is "ABC". Let's also assume that your FooFooActivity class takes you to this ABC class. Following steps will take you through how to do the navigation part.
I. Inside the onCreate method of your FooFooActivity class, you already have the setContentView. Now, after that line, add the following lines:
Button button = (Button)findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent(FooFooActivity.this, ABC.class);
startActivity(intent);
}
});
By Passing an Intent you can guide yourself/your user to the desired screen/activity.
II. Please keep in mind that in your ABC class, imply the same onCreate method and place your XYZ layout inside the setContentView like this: setContentView(R.layout.XYZ);
III. In your manifest file, after your
<activity
android:label="#string/app_name"
android:name=".FooFooActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
add the following:
<activity
android:name=".ABC"
android:label="#string/app_name"
>
</activity>
Once you're done with these steps, run your program.
Please note that this is just for showing 2 screens to your user. You need to repeat it for 20+ times. I don't know/see any other way.
As far as your layouts are concerned, I'd suggest you stick with Relative Layout or a Linear Layout. Generally most of the "normal" layouts can be achieved by either of these or their combination. If you want more, you can always find help on Android Developers' Site or Stack Overflow. Anyway, there are lot of other things that I haven't been able to explain here, but I intend to in due time. You can always refer to great books such as Hello Android, Programming Android, and Learning Android. Even CommonsWare - Mark Murphy has his set of books that are pretty popular. You can always start off with any of them.
Hope this helps. All the best!
EDIT FOLLOWING YOUR UPDATION :
Of course it will return the last activity because I presume you've the following piece of code with your exit button:
Button exit = (Button)findViewById(R.id.button2);
exit.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
finish();
}
});
So, basically what you're doing is ending that particular ABC/Main Activity. That means, android will take you to the previous screen/activity. That's all. If you keep the same layout and plan it to use it for different activities, everything will simply get confusing. With just 2 screens/activities, it's confusing enough for you as of now. Imagine what might happen with 20+. Well, the design is ultimately left to you. That's all I can say.

Categories

Resources