• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to keep app running in background with screen off

I have an app that works great while the screen is on, but as soon as the screen is off it start slowing down until eventually in a couple of minutes is off. I notice that the mainActivity in the android studio tester stops if I turn the screen off, as soon as I turn it on the screen the main activity goes live again and the app works fine again. I have tried BATTERY_OPTIMIZATIONS, DATA_RESTRICTIONS, but it doesn't seems to work. can anybody help me on how to keep the mainActivity from stopping while the screen is off?

I have read about foreground service and tried too but I dont seem to find any service that works with web view

thanks. Attach is a pic of the main activity stooping in the android studio test environment, the green part is the app with the screen on

this is the code that I am using

public class MainActivity extends AppCompatActivity {
private WebView webView;

@override


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

webView = findViewById(R.id.wb);




WebView webview = new WebView (this);
setContentView(webview);
webview.loadUrl("http://www.apple.com");
webview.getSettings().setJavaScriptEnabled(true);


}

public void startService(View v){
String input = webView.getUrl().toString();

Intent serviceIntent = new Intent(this, RunService.class);
serviceIntent.putExtra("inputExtra", input);

startService(serviceIntent);
}
}

Attachments

  • mainactivity.PNG
    mainactivity.PNG
    11.2 KB · Views: 310

Installing Google Play via Android Studio (while rooted)

Hi guys,

I have been going through hell and back over the last week trying to get Google Play installed on Android Studio. Of course there are images that come with Google Play pre-installed, but I cannot root those images using adb root.

Therefore, I have installed an Android image in Android Studio that supports Google APIs and have been trying to manually push OpenGApps onto the image. This has been a nightmare. I finally got it to work and now a few days later Google Play is no longer installed and the Pixel Launcher just keeps crashing.

Here's what I've tried thus far:

I ran into an installer that someone wrote in bash over here https://gist.github.com/cunneen/1c0d9717f8ce5ea76900ba32fa037047 and tried to replicate the results manually. Last week, things were fine. However, today, I have tried repeating the process since Google Play decided to uninstall itself.

Here's the error that I'm running into along the process:

Code:
[myuser@mbp.local:...x86-9.0-stock-20190618/Core]$ "${ANDROID_HOME}/emulator/bin64/e2fsck" -f "${HOME}/.android/avd/${AVD}.avd/system.img"                  8:11AM/06.27
e2fsck 1.42.13 (17-May-2015)
ext2fs_open2: Bad magic number in super-block
/Users/myuser/Library/Android/sdk/emulator/bin64/e2fsck: Superblock invalid, trying backup blocks...
/Users/myuser/Library/Android/sdk/emulator/bin64/e2fsck: Bad magic number in super-block while trying to open /Users/myuser/.android/avd/Pixel_2_API_28.avd/system.img

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
or
    e2fsck -b 32768 <device>

This seems to be the only hiccup that I've encountered now when trying to re-install Google Play onto this Android image. I have tried the previous step, which is to copy the Android system image from $ANDROID_HOME/system-images/android-28/google_apis/x86/system.img to replace the system.img in the AVD folder, but I still get this error.

Has anyone been able to successfully accomplish this, or is this not even possible? It seems that when I ask this question on StackOverflow, there's crickets... as if no one ever does this or something.

Android Q WEP connection

I'm trying to connect to a WEP network using the latest Android Q Beta 4. The old style off communicating was quite straight forward. Using something like:

Java:
WifiConfiguration connection = createApConfiguration(ssid, password, "WEP");

int res = wifiManager.addNetwork(connection);

However in the Q release this has been deprecated. https://developer.android.com/refer...ddNetwork(android.net.wifi.WifiConfiguration)

I need to connect to a "WEP" network and I don’t see any option to set such configuration. The latest API im using is below.


Java:
val specifier = WifiNetworkSpecifier.Builder()

.setSsid("NetworkID")

.setIsHiddenSsid(false)

.setIsEnhancedOpen(false)

.setBssidPattern(MacAddress.fromString("10:03:23:00:00:00"), MacAddress.fromString("ff:ff:ff:00:00:00"))

.build()


val request = NetworkRequest.Builder()

.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)

.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)

.setNetworkSpecifier(specifier)

.build()


val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager


val networkCallback = object : ConnectivityManager.NetworkCallback() {


override fun onAvailable(network: Network?) {

Log.d("AVAILABLE", "onAvailable")

}


override fun onUnavailable() {

Log.d("UNAVAILABLE", "onUnavailable")

}}


connectivityManager.requestNetwork(request, networkCallback)



Any help would be very much appreciated

Thanks in advance

Stereo / Surround sound problem

Hi ! Recently I bought an Samsung S9+. What I did noticed, after making the updates and installing some games, is that, after a few minutes, the music ... changes... It's like it's not stereo anymore (or, better said, that surround feeling disappears) . It just sounds worse...

Noticed this on PUBG Mobile (high settings, in the main menu), Pako 2 and Real Racing 3 (while racing). And after around 5 mins from the game's start.

Is this normal for an brand new S9+ (idk, overheating), or should I have it replaced/fixed (or is it any way to fix it myself) ?

Oh, and Dolby Atoms is on, and also I have an Clear View Cover on it (again, may be overheating, idk).

Thanks in advance !

How to easily copy alpha-numeric PIN code

Hi guys,

Context: I am working on an app that sends the user a PIN code to check the phone number ownership. Due to company security restrictions, the PIN code has 6 characters, made from letters and digits (ex: AB12C3).

Question 1: How to easily copy the alpha-numeric 2FA code from the default SMS app? I did find a lot of articles about copying numeric codes, such as 12345, but I want an easy solution (no 3rd party apps) that can allow me to easily cop ya PIN code such as AB12C3.I only want to press on the code for a second to have it saved to the clipboard. I do not want to go through "Select text" -> manually select the PIN code. Is there a solution for this?

Thank you!

where to mount phone in the car while driving for safety

  • windshield -It places the phone at eye level and is extremely cheap and easy to install - you can effortlessly stick and remove it from the glass
  • Dashboard - By placing your handset on the dashboard you can easily interact with the phone without affecting your windshield view
  • Vents - vent mounts are the best suited for people who don't want to have their handsets mounted in their cars all the time.
  • Rear View Mirror - Mounting the device on the rear view mirror does not require much effort to view your phone screen when you are driving the car
  • Cup Holder - This helps the driver to navigate the handset without any trouble. Moreover, one can easily remove it without any residues.

LocationManager problem

Hello guys!
I have the following code to request location update, but it doesn't work. I get this error "Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityException".
Can you help me with some answers?
Thank you a lot!

The code that I have:
if (mLocationManager.getAllProviders().indexOf(LocationManager.GPS_PROVIDER) >= 0) {
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 0, this);
} else {
Log.w("MainActivity", "No GPS location provider found. GPS data display will not be available.");
}

if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
showGpsDisabledDialog();
}

mLocationManager.addGpsStatusListener(this);

PS: I included user-permission in AndroidManifest. I am running sdkVersion 27

[Released][Open Beta] ASTRA PRIME – Challenging puzzle arcade hybrid!

1RBP6UWl.png



Hi everyone, I am an Australia based indie developer, releasing a free to play mobile game. :D

Currently in open beta so please check it out on google play using the link below.

Hope you enjoy it and look forward to hearing your feedback!


HIGHLIGHTS:
  • Fuse elements together to stop the star going supernova
  • Addictive and challenging gameplay
  • Three game modes with google play leaderboards and achievements
  • Music by awesome composer WaterFlame
  • Small download size and quick play sessions.
  • NO ADS


ASTRA PRIME

https://play.google.com/store/apps/details?id=com.prempixel.astraprime


F7ZttiF.png

CsTJvvX.png


SOCIAL :
TWITTER | YOUTUBE | WATERFLAME

Go Launcher - How can I disable home screen notifications?

I've been using go launcher flawlessly for months with no issues, but it seems like there's just been an update that I absolutely hate. ringtones free
As of yesterday, when I press my home button, I don't actually go home, but to an intermediate screen filled with my Facebook and email notifications and the like that I must dismiss to actually go home. I despise it. I pressed home, I want to go home, I'll with my notifications on my own time!!
Is there any way I can disable this feature so that I don't have to uninstall the launcher? It's been by far my favorite up until now. Download Samsung klingeltone herunterladen free

In house server with Android clicker for quizzing

There are a number of websites now that allow people to host quizzes. Many of them have an app that can be installed on a smart phone - the student presses a "button" on the phone to answer the question. I am hoping to find an app to put on a computer that is in the classroom rather than having to tether to the internet. Does anyone know what words I should use to search for this?

Help Strange behavior: Calling by using "recent calls" list calls random numbers.

Hello
Hoping someone can figure out what is going on. Yesterday I called my wife by pressing her contact in the "recent calls" list, however the number called is not hers, but some random number. Her contact on my phone has not changed. Even more weirdly my mother-in-law came to me with the same problem (she has a Doro phone for elderly people). We have so far only problems with my wife's number.

When I looked at my call history more closely I noticed that these calls were registered to/from my wife but her name is spelled without spaces. It is spelled with spaces in my contacts. The contact without spaces does not exist in my contacts.

Is this some kind of of virus?

Amlogic MXQ-Pro TV box - HDMI off

Have a problem of HDMI not restoring when I turn monitor back on.
During music play, (or long pause during video play) I need to power off monitor because waste precious solar battery power.
Is there a system config file that has line I can modify to eg: disable HDMI off when monitor power down.
or
A way to turn HDMI back on easily, (only way at present is to power down). I suspect it changes over to composite output when monitor off.
I have used RFObasic in the past to make small apps, maybe could do something to respond to remote key press if I knew what to set.

Thanks

Running Ttl budget app

I am looking for a budgeting / checkbook app that will do the following.
• Allow recurring payments and recurring bi-weely income.
• allow me to look at future dates (up to 8 weeks balances) if I have any future times when I will have a negative balance based on recurring bills.
• allow me to set up loan payment showing debt left after monthly payment.
• prefer off-line and free. But am flexible.

Help Delete metadata

Hello World

I think I messed up. I tried to move my camera pictures from my Samsung Galaxy S6 to my computer. I tried several ways, in the end I found an app called SSHelper. This app lets me connect to my phone with a normal ssh connection. Like this I downloaded all my pictures and was happy - for a moment. Now I have the following file, that is 11.5 GB in total:
DCIM/.metadata/HighLight.meta

I can't delete this file, since I don't have the permission to do so. I found an app that would let me delete the thumbnails.

Filter

Back
Top Bottom