I'm developing app for Zebra device model MC33.
I like how internal apps ask to enter admin pattern (password) when I open Settings or others. In my app I have settings activity and I would like to ask user for authorization.
What I want to have is:
https://imgur.com/gallery/BwpAAPI
I used class DevicePolicyManager and then call for lock screen. (code is below)
But it turn off the sceen completely (it become black) like the device is switch off. Then I can enter pattern to turn it on.
This is screenshot what I get after using DevicePolicyManager:
https://imgur.com/gallery/TnHgDgs
DevicePolicyManager policy = (DevicePolicyManager)
getSystemService(Context.DEVICE_POLICY_SERVICE);
policy.lockNow();
Such behaviour may be misleading. Do you have idea how to call for proper screen in my app?
Related
I have to create an app, which detects user inactivity, and then start activity which displays some videos with WebView, and then when displaying with WebView is finished, it has to play videos from SDCard. I've already handled part with WebView and SDCard (with JavaScriptInterface etc.)
This application has to work with API 19 all the way to the newest one.
The question is - Is there a possibility to detect if user is inactive and start my application, or keep the app running in background, and then start activity in the foreground after the user becomes inactive for certain time?
I'm not trying to play ads, when user is not looking at his screen. Application is for my client, who have stores with all kind of electrical equipments, including smartphones. The goal is to play video presentations with hardware details specific for each smartphone (informations about processor, ram, camera, screen etc.).
In short: I have to make an app which is similar to "Demo Apps" created for example by Samsung (playing some kind of presentations on screen).
So far I've read and tested things like:
1) BroadcastReceiver with combination of ACTION_SCREEN_OFF / ACTION_SCREEN_ON events.
Receiver works properly, I can detect this event and then start activity, but... The screen is already off so i can't see the displayed activity - it's visible running in the foreground after unlocking the phone. Is there a way to unlock the phone when the event is received?
That's my code so far.
EventReceiver Class:
class EventReceiver: BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
StringBuilder().apply {
append("Action: ${intent.action}\n")
append("URI: ${intent.toUri(Intent.URI_INTENT_SCHEME)}\n")
toString().also { log ->
Log.d(TAG, log)
Toast.makeText(context, log, Toast.LENGTH_LONG).show()
}
}
if (intent.action == Intent.ACTION_SCREEN_OFF) {
val i = Intent(context, MainActivity::class.java)
context.startActivity(i)
}
}
}
MainActivity Class:
val br : BroadcastReceiver = EventReceiver()
val filter = IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION).apply {
addAction(Intent.ACTION_SCREEN_OFF)
addAction(Intent.ACTION_SCREEN_ON)
addAction(Intent.ACTION_BOOT_COMPLETED)
}
2) Foreground Services - I read that this is a great way to make some asyc stuff in the background and show notifications to user. Is there a way to start the activity with it?
3) Job Scheduler
4) Daydream / Dream Service - it actually works great with almost every API and manufacturer, but.. there's no way to set the app as Screen Saver on Huawei/Honor smartphones, at least from phone settings, I've read that this is possible with ADB etc. but this is not an option that I can use here.
It seems that none of these fullfill my expectations.
I would like to display a twitter user profile without having the app prompt the phone user for creating an account or login information.
public void openTwitter(View view){
try
{
// Check if the Twitter app is installed on the phone.
getPackageManager().getPackageInfo("com.twitter.android", 0);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.twitter.android", "com.twitter.android.ProfileActivity");
intent.putExtra("user_id", 01234567L);
startActivity(intent);
}
catch (PackageManager.NameNotFoundException e)
{
// If Twitter app is not installed, start browser.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/xxx")));
}
}
The code opens the twitter app and prompts the phone user for account creation before viewing profile xxx. I would like to simply view profile xxx without creating an account or logging in.
Welcome to StackOverflow. Please check out how to ask a good question first. Your question doesn't describe a specific problem and therefore can't be "solved". It also isn't specific enough for anyone to point you in the direction of methods to use to achieve your goal.
That being said, if you just want to display anyone's profile, implement the Twitter API in your app and make the right REST calls and you should get the information you want to display.
If you want the user's profile specifically, there's literally no way around the user logging into their account with the API, unless they previously define their username in your app.
If you just want to display the profile and don't care about designing the information yourself, you could use a WebView to open the link to the profile you want to open, or use UIApplication.shared.open to open a link outside your own app.
I've been using onTaskRemoved() method in a Service to detect when an app was removed from the device's RECENT list by swiping it away. I preform some logging and some other operations that need to take place when this happens. It works perfectly. For android below 6... But background service is being killed after swiping off in android 6.
#Override
public void onTaskRemoved(Intent rootIntent) {
Log.e("ClearFromRecentSsss", "sttttts");
Intent intent = new Intent("in.com.example");
sendBroadcast(intent);
}
Some manufactures like xiaomi, Oppo have their own background strategy which is autostart. You need to redirect user to auto start activity and tell user to switch on:
Go like this and allow your app to autostart:
Settings > permissions > Autostart
Autostart setting varies by manufactures like in Xiaomi you can find it in their SecurityCenter app.
Autostart is blocking your service to restart, So turn it on manually and the check again . I'm afraid there is no inbuilt API to do so . So you need to redirect users to specified screen as per manufactures to turn auto start On. Have a look at Links below:
link1
link2
Can someone explain what is the difference in getting permissions in one of the two:
1) via code, on first Fb login:
setContentView(R.layout.facebook_login);
LoginButton authButton = (LoginButton) findViewById(R.id.authButton);
// authButton.setReadPermissions(Arrays.asList("user_status"));
authButton.setReadPermissions(Arrays.asList("basic_info",
"user_birthday", "user_interests", "user_likes", "email",
"user_location", "publish_actions"));
2) via Facebook developer page:
if there is none, what is the duplication?
App Details --> Configure App Center Permissions
In (1), i.e. in code, you can choose at execution time which permissions to ask for. This means you can, for example, initially ask for just public_profile, and then later when the user wants to share something you can ask again for "publish_actions".
In (2), you are setting which permissions the user will grant if they start playing via the app centre (e.g. https://www.facebook.com/appcenter/yourgame). In this case the set of permissions you choose will be shown to the user in the app center before they start your game. When they press Play in the app centre they are granting the chosen permissions, so you don't need to call a login method from within your code.
These two sets of permissions can be different.
Hy.
I have a situation with an UiApplication for Blackberry 5.0.0 OS that may be of interest to the communnity or with wich someone could help me.
My application implements the PhoneListener interface to be notified when an outbound call is detected on the device (callInitiated method). Upon that, the app simulates a disconnect key press to cancel the call. Then, a Dialog is launched and some action is required on the user side...
All works well when the number is dialed through the phone app, the dialog is launched, the phone app dissapears and the dialog remains on screen waiting for user action. But if the user dials through the contacts list, speed dial or numbers in web pages, the dialog appears but quickly dissapears when the phone app dissapears (after the call is artificially disconnected).
I'll be paciently awaiting for a response from someone that can shed some light on this... thanks.
The solution:
The dialog must be created in another way. I was using Dialog.ask by the way.
Screen screen = null;
synchronized(UiApplication.getEventLock()){
UiEngine ui = Ui.getUiEngine();
screen = new Dialog("<dialog text>", <options>, <values>, 0, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION));
ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_MODAL);
}
int appMethodAsked = ((Dialog) screen).getSelectedValue();
To note that, a key detail for this code to work is the UiEngine.GLOBAL_MODAL value passed to the pushGlobalScreen method. Without this, the same thing described as the problem will happen.