天道酬勤,学无止境

android-6.0-marshmallow

getUidTxBytes(int uid) always return 0 in android 6.0

I am trying to get network traffic stats of all apps. I just print total network traffic of every application in my device. The code is working fine in android 4.4 and 5.1 devices but in android 6.0 device it always return 0 for all applications. Anyone can please tell me why this happened in android 6.0 devices. protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); for(ApplicationInfo app : getPackageManager().getInstalledApplications(0)){ long tx = TrafficStats.getUidTxBytes(app.uid); long rx = TrafficStats

2021-07-12 10:42:39    分类:问答    android   android-6.0-marshmallow   android-trafficstats

trying to add marshmallow permissions using “Permissions Dispatcher”

I'm trying to use the plugin Permissions Dispatcher(https://github.com/hotchemi/PermissionsDispatcher) to handle Marshmallow runtime permissions in a GPSTracker class which I want to call in a fragment, but I'm still getting the error "Call requires permission that may be rejected by user: Code should explicitly check to see if permission is available..." I think I need to add something to MainActivity but I can't figure out what. GPSTracker.java package me.paxana.alerta.adapter; import android.Manifest; import android.app.AlertDialog; import android.app.Service; import android.content.Context

2021-07-03 07:13:56    分类:问答    java   android   plugins   permissions   android-6.0-marshmallow

Image file is empty on return from activity on Android

Using code from this answer: https://stackoverflow.com/a/12347567/734687 I use the following code to let a user submit a picture to my Android application. private void openImageIntent() { File outputFile = null; try { outputFile = File.createTempFile("tmp", "face", getCacheDir()); } catch (IOException pE) { pE.printStackTrace(); } mOutputFileUri = Uri.fromFile(outputFile); // Camera. final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = getPackageManager()

2021-07-03 05:19:59    分类:问答    android   android-6.0-marshmallow

Android sensor sampling rate won't drow below 60 hz

I'm reading out the accelerometer sensor on a Sony Smartwatch 3. Since the Android Wear 1.5 update the sampling rate won't drop below about 60hz, regardless weather I use SENSOR_DELAY_NORMAL, SENSOR_DELAY_UI or SENSOR_DELAY_GAME. Before the update SENSOR_DELAY_NORMAL resulted in a sampling rate of about 18 samples/seconds. accelerometer.getMaxDelay()still returns 62500, which would be 16 samples/sec. I also tried setting the desired delay directly, when registering the sensor with sensorManager.registerSensor(this, accelerometer, 62500) but this doesn't work either. Has anybody any idea of how

2021-07-03 01:33:25    分类:问答    android   wear-os   android-6.0-marshmallow   android-sensors   sensormanager

Android Marshmallow Permission for my eclipse project not working

I have created an application using eclipse IDE. And now its crashing on Marshmallow for various permissions say contact. After lot of searching I come up with no result. It is showing error in checkSelfPermission, requestPermissions etc. on CONTACT from Manifest.permission.CONTACTS. I think the solutions are working on android studio projects. So let me know same for eclipse project if any one know it.

2021-07-03 01:14:21    分类:问答    java   android   eclipse   android-6.0-marshmallow   android-permissions

How to ask multiple permissions at the same time in android 6.0+

i want to ask the user to accept the following permissions at the same time(one by one), the permissions are like: checkLocationPermission, checkReadSMS, checkCallingPermission, checkReadState, checkContactWriteState. So, how i can ask all these permissions in my first screen itself. Please help me out in this regard. Thanks in advance.

2021-07-02 17:06:23    分类:问答    java   android   android-studio   android-6.0-marshmallow

Instagram-Links in native WebView on Marshmallow

Recently I noticed a really strange bug that appears, when you try to call https://www.instragram.com/ in a webview when your smartphone runs Android 6 Marshmallow. The problem is, that the screen remains blank all the time, just with that little instagram-icon in the middle - kind of a loading screen it seems. It looks like this: This also happens when you view Instagram pages in your browser without having JavaScript enabled - it seems like the page does not load without JavaScript. The strange thing is, that I did the following setttings in my webview: WV_Downloader.getSettings()

2021-07-02 08:05:27    分类:问答    java   android   webview   instagram   android-6.0-marshmallow

DatePickerDialog not working as expected

I have an EditView in which I am trying to bind DatePickerDialog. Its working well with the api 19. but when tested on api version 25 Marshmallow the calendar becomes white and when selected some date the EditView is not populated as well i.e I am unable to set date in Marshmallow. Code: warrantyExpEt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new DatePickerDialog(getContext(), date, myCalendar .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show(); } }); final DatePickerDialog.OnDateSetListener date =

2021-07-02 06:42:44    分类:问答    android   android-6.0-marshmallow   datepickerdialog

ACTION_ASSIST intent on Marshmallow (Android 6.0)

Is there a way to use the ACTION_ASSIST (Google now) intent on Android 6.0? I think this might have changed with the now on tap feature - but perhaps (hopefully) there is still a way to hook into this.

2021-07-01 21:41:12    分类:问答    android   android-intent   android-6.0-marshmallow

无法在 android marshmallow 6.0 中接听来电(Can't answer incoming call in android marshmallow 6.0)

问题 我正在创建一个呼叫应用程序。 这是适用于 android 4.0 和 5.0 的自动回答; 而当我有来电时,接听电话按钮有效,但在 android 6.0.0 上不起作用。 我测试了这篇文章的答案,但它也不起作用:在 Android 6.0 中接听来电 传入活动: @Override public void onClick(View v) { switch (v.getId()) { case R.id.imgaccept: { if (Build.VERSION.SDK_INT >= 21) { new Thread(new Runnable() { @Override public void run() { try { Runtime.getRuntime().exec( "input keyevent " + KeyEvent.KEYCODE_HEADSETHOOK ); Intent intent = new Intent(getApplicationContext(), OutGoing.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); intent

2021-07-01 09:17:31    分类:技术分享    android   android-6.0-marshmallow   android-permissions   incoming-call