android: Activity as a subscreen of a larger screen? - android

I am hoping to save some time with a project and wonder if this is possible to do.
Currently there are some android phone screens that have already been developed by a former colleague. I am developing a new screen for a tablet that needs to have the content of an existing screen that he developed appear as a sub-screen (say a little box in the bottom right corner of the screen. This is aesthetically ok because the existing screen is small (phone). The screen I am developing is for a 10.1" tablet, so it only takes up a tiny portion of my screen.
However, the problem is that he had the screen all coded up in a nicely and integrated with an associated Activity. I am hoping to just reuse it by calling an Intent from my screen/activity unit, modifying it as little as possible.
QUESTION: Is it possible to have an activity appear as a subscreen of another activity?
Mind you I know that you can launch a fire and forget activity from one screen with an Intent + startActivity(). But that will only take the new screen appear on top of the old screen.
Where as I want the new screen to appear as a subscreen of the existing screen. Any idea?
All pointers and recommendations are appreciated. TIA

You're looking for Fragments!
From the Android documentation:
A Fragment represents a behavior or a portion of user interface in an
Activity. You can combine multiple fragments in a single activity to
build a multi-pane UI and reuse a fragment in multiple activities. You
can think of a fragment as a modular section of an activity, which has
its own lifecycle, receives its own input events, and which you can
add or remove while the activity is running.
If you're developing for devices running Android versions prior to 3.0, take a look at the compatibility library, which allows the use of Fragments in versions 1.6 onwards.
Further, if you're developing for phones and tablets, you can reuse the same Fragment in both interfaces.

Related

Android - How to make an app displayed in a small screen while the rest of screen is still visible and clickable

I have a request to reduce my app screen size and the rest of the screen space are still visible and clickable for user.
It means when my app is running, user can click some icons or buttons outside of my application.
What I found are using such as Dialogs or Multiple Fragments. However, those solutions are useful when all are in your main activity. But in my case, the rest of the screen is from Home screen or other screens, not from my app screen.
Could someone have an idea for this kind of concept?
Here is my request concept image
Searching from internet
You don't need to do anything for this. Android supports splitt screen since Android 7.0.
Alternatively you can enable Picture-In-Picture mode for your app which is supported since Android 8.

Viewpager like Home screen with drag rearrange and swipe down to delete

I have started working on making a simple launcher app. I have already gone through many posts and source code of various launchers but I am really stuck at the home screen thing. I just want to create a simple view pager and on long click of it I want it to behave like android stock launcher where user can drag and drop screens to rearrange it and may delete it by swiping down to the cross button.
I am really confused as there is no proper documentation of how things happening in android stock launcher
Please tell me how to achieve this properly. If anyone has extracted that code and give it to me it will be a great help. Links are appreciated.
Thanks!
The standard home screen is implemented as a single large view, with each screen being a child view. Each of those individual screens then lays out icons and app widgets according the grid appropriate for the device.
The way the swiping behavior works is by overriding onInterceptTouchEvent and onTouchEvent. It's tricky because there are so many things that a touch could be doing: the user could be tapping on an icon, swiping to the next screen, or starting a long-press. When you implement one of these behaviors, you have to make sure you don't get in the way of another one.
Once the user is doing a long-press, your launcher app enters a different mode, and the event processing behaves differently in this mode. That is, it implements the standard drag-and-drop behavior. This is tricky too.
I spent two years of my life working on the home screen app for a major device manufacturer. It's complicated, and I'd recommend that you have a good reason for diving into the project.

Get location of android widget

Is there any way to retrieve position/location of android widget which is activated in android device, like whether its on lock screen, home screen etc. In lock screen is it the main widget displayed.
On Android 2.1 and later, with some select home screens, you can find out where an app widget resides when it is clicked via getSourceBounds() -- this value is attached to any Intent you spawn via a PendingIntent via setOnClickPendingIntent().
However:
this only works on Android 2.1 and newer
not all home screens might do this, as this is part of the Launcher code IIRC
the coordinates are in pixels IIRC
there is no way to interrogate the home screen to find out this information any other way, since there is no API to interact with the home screen
Hence, I think your stated goal ("Depending on whether it's on the top of the desktop or at the bottom different layouts for the widget will be chosen") is impossible, I think.

Switching activities on lockscreen shows lockscreen

So I'm making an app for my company, for a android tablet to be used like a "kiosk". Users should only be able to use this one app, and be able to do nothing else on the tablet.
I've found a solution by using WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED on the activities. However, when I switch to another activity in my app, the leaving activity fades out, shows the lock screen quickly and then the next activity appears.
I'm guessing that this is because the FLAG_SHOW_WHEN_LOCKED is in onCreate(), as opposed to earlier in the Activity creation process.
Is there anywhere else I can put this flag, or any other way to prevent the lockscreen to be shown between activities? It's not a huge issue, but it is a poor user experience.
It is a Samsung Galaxy Tab 10.1 Running ICS 4.0.3.
I was able to best fix this by using Fragments and using FragmentManager to swap out the fragments in the activity, so the lockscreen was never shown, since I never left the activity. The android developer guide has a good example for this.
http://developer.android.com/reference/android/app/Fragment.html

How to place a screen control in the home screen that will be always visible

I need a screen control (possibly but not mandatory an app widget) that will seat
on Android's homescreen and will always be visible to the user - even when he scrolls the homescreen to the next page.
Please help me if any body have done this before.
I think the only way you will be able to do this is if you implement your own Launcher.
The functionality that you're looking for, being able to place a static widget on every screen of the launcher regardless of how many screens they have, isn't currently available in Android, nor any of the launcher apps out there (Go launcher, ADW, Launcher pro etc) nor any of the versions of Android which have been rewritten by the phone manufacturers (HTC's Sense, Samsungs Touch Wiz etc)
It's a big job to write a Launcher yourself, but the stock Android Launcher code is available to play about with from https://android.googlesource.com.

Categories

Resources