Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	_vendors/stock_android.md
  • Loading branch information
Artaud committed Sep 1, 2020
2 parents d90c6f9 + 505c231 commit dfdc85f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
7 changes: 4 additions & 3 deletions _vendors/stock_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ manufacturer:
- google
redirect_from: /vendors/stock_android.html
explanation: "
On Pixels and Nexuses you have the least chance something goes wrong with background processing, but still there are several places to look at!
On Pixels and Nexuses you have the least chance something goes wrong with background processing, but still there are
several places to look at!
Some use-cases are no longer possible or paradoxically more battery consuming (e.g. gathering sensor data through sensor batching,see [Solution for developers](#dev-solution)) with the introduction of [Doze mode](https://developer.android.com/training/monitoring-device-state/doze-standby) in Android 6+ and you may need to opt the app out of battery optimizations to make it work properly.
Also a serious Doze mode bug in Android 6.0 even prevented foreground services to do their job (see [Solution for devs](#dev-solution) for workaround), but luckily this was fixed in 7.0.
Also a serious Doze mode bug in Android 6.0 that prevented foreground services from doing their intended job (see [Solution for devs](#dev-solution) for workaround), but luckily this was later fixed in 7.0.
After Android 8 users or even the system (Adaptive battery in Android 9) can decide to prevent your apps' background processes from working and you may need to check the Background restrictions (or limits) option in your phone settings.
After Android 8, users or even the system (Adaptive battery in Android 9) can decide to prevent your app's background processes from working and you may need to check the Background restrictions (or limits) option in your phone settings.
"


Expand Down
68 changes: 39 additions & 29 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,41 +92,51 @@ scheme:
}
````

Android example (Java):
Android example (Kotlin):
````
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... voids) {
try {
return ((JSONObject) new JSONTokener(
InputStreamUtil.read(new URL("https://dontkillmyapp.com/api/v2/"+Build.MANUFACTURER.toLowerCase().replaceAll(" ", "-")+".json").openStream())).nextValue()
).getString("user_solution").replaceAll("\\[[Yy]our app\\]", context.getString(R.string.app_name));
} catch (Exception e) {
// This vendor is not in the DontKillMyApp list
// Use this method in your ViewModel
fun getDKMAData() {
viewModelScope.launch(Dispatchers.IO) {
val result = try {
val manufacturer = Build.MANUFACTURER.toLowerCase(Locale.ROOT).replace(" ", "-")
val url = URL("https://dontkillmyapp.com/api/v2/$manufacturer.json")
val json = JSONTokener(url.readText()).nextValue() as JSONObject?
json?.getString("user_solution")?.replace(Regex("\\[[Yy]our app\\]"), yourAppName)
} catch (e: Exception) {
// Vendor not present in the DontKillMyApp list
null
}
return null;
}
@Override
protected void onPostExecute(String result) {
if (result != null) {
WebView wv = new WebView(context);
wv.loadData(result, "text/html; charset=utf-8", "UTF-8");
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
new AlertDialog.Builder(context)
.setTitle("How to make my app work")
.setView(wv).setPositiveButton(android.R.string.ok, null).show();
withContext(Dispatchers.Main) {
when (result) {
null -> TODO("Handle lack of result")
else -> TODO("Pass back result to your UI here")
}
}
}
}.execute();
}
// Use this method in your UI, Activity or Fragment
fun showData(result: String) {
AlertDialog.Builder(context)
.setTitle("How to make my app work")
.setView(webview.loadDKMAData(result))
.setPositiveButton(android.R.string.ok, null)
.show()
}
fun WebView.loadDKMAData(result: String) {
loadData(result, "text/html; charset=utf-8", "UTF-8")
webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
loadUrl(url)
return true
}
}
}
````


Expand Down
3 changes: 2 additions & 1 deletion press.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ menu: true
* [MalayMail](https://www.malaymail.com/s/1712481/does-your-smartphone-kill-important-apps-here-are-the-top-offenders-and-how)
* [Frandroid](https://www.frandroid.com/android/560912_nokia-oneplus-huawei-et-xiaomi-epingles-pour-tuer-trop-facilement-vos-applications)
* [Android Portal SK](https://androidportal.zoznam.sk/2019/01/programatori-nestastni-vyrobcovia-prehanaju-setrenim/)
* [Tweakers](https://tweakers.net/nieuws/147914/app-ontwikkelaars-stellen-ranglijst-agressiefste-appkillers-op.html)
* [Tweakers](https://tweakers.net/nieuws/147914/app-ontwikkelaars-stellen-ranglijst-agressiefste-appkillers-op.html)
* [XDA-Developers](https://www.xda-developers.com/phone-software-killing-apps-background/)

0 comments on commit dfdc85f

Please sign in to comment.