M-WaJeEh

1

votes
2

answer
328

views

Possible memory leak Android

I ran this command adb shell dumpsys meminfo and got Objects Views: 74 ViewRootImpl: 1 AppContexts: 3 Activities: 1 Assets: 4 AssetManagers: 4 Local Binders: 11 Proxy Binders: 20 Death Recipients: 0 OpenSSL...
M-WaJeEh
1

votes
2

answer
0

views

Insert one record in sqlite android using contentprovider

I have a custom content provider and I need to insert one record at a time when user clicks on some button, and it is not too often. I was wondering that should I do this insert in background thread (AsynchTask, etc) or should I just insert it on GUI thread? Right after insertion I have to update GU...
M-WaJeEh
1

votes
1

answer
869

views

Get drawable for different screen density at runtime

I want to print sizes of all drawables at run-time. So if I am on hdpi device then I can print the size of hdpi drawables but how to get access to, lets say mdpi and xhdpi as well? I can get access to all drawables resource ids with following code: final Class c = R.drawable.class; final Field[] fie...
M-WaJeEh
4

votes
1

answer
2.3k

views

When and why PARTIAL_WAKE_LOCK is required?

All other wake locks makes sense e.g. developer want screen not to go off while performing something. But in partial wake lock documentation says that : If you hold a partial wake lock, the CPU will continue to run, regardless of any display timeouts or the state of the screen and even after the use...
M-WaJeEh
3

votes
1

answer
294

views

Is it ok for view to ask for data from ViewModel in MVVM?

I have been reading about MVVM pattern. View is supposed to observe for changes in ViewModel and act on it accordingly but I am confused if following code in View is ok in MVVM architecture. fun onClick(view:View){ showUser(viewModel.getUserDisplayName()) } Here View is not observing for a change, i...
M-WaJeEh
1

votes
1

answer
124

views

Multiline `ReplacementSpan` drawing issue

My custom replacement span works as long as text is not too long but as soon as text is longer than one line, span drawing completely breaks apart. My understanding is that draw() gets called twice in this case causing span to draw twice. There is no way to differentiate that second draw call from f...
M-WaJeEh
2

votes
3

answer
180

views

Is this layout possible in Android?

This layout seems simple but I can't find any way to do this solely in xml using LinearLayout or any other layout without changing properties dynamically. Here is what I want, if text is short then layout should be totally wrapped as shown in figure: But in case TextView contains longer text then it...
M-WaJeEh
4

votes
1

answer
1k

views

Why Lint shows warning when using in (inch) or mm (millimeter) units as dimension?

Documentation clearly says that mm and in are screen size dependent. mm Millimeters - Based on the physical size of the screen. in Inches - Based on the physical size of the screen. But when I use them, Lint says: Avoid using 'mm' as units (it does not work accurately on all devices); use 'dp' ins...
M-WaJeEh
3

votes
2

answer
2.3k

views

Spinner popup background color issue

The following code produces an issue (see attached images) on Asus Intel Zenfone. Every other device I tested on is showing it fine, meaning the black area around the Spinner popup is transparent. Any way to get rid of black color? I have Theme.AppCompat.Light.NoActionBar applied to the Activity.
M-WaJeEh
4

votes
3

answer
8.1k

views

java.lang.SecurityException: Permission Denial: opening provider

I start image picker intent using: final Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(intent, PICK_IMAGE); and in onActivityResult() I get uris of all picked images and...
M-WaJeEh
3

votes
0

answer
630

views

How to get the bounded rectangle of a particular word in a TextView/EditText in android

I have a multi-line TextView and I want to get the bounded rectangle of a particular word in that TextView. I have ClickableSpan Text in TextView, so when user clicks on a word, I want to show him/her a small window above that word. But to achieve this I must know the location of that word in that T...
M-WaJeEh
2

votes
2

answer
2.7k

views

Android Music File Chooser Intent Issue

I have an app that lets user choose music file from sdcard. To launch chooser intent I am using Intent intent = new Intent(); intent.setType('audio/*'); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult( Intent.createChooser(intent, 'Complete action using'), 0); But I am getting d...
M-WaJeEh
1

votes
1

answer
450

views

Android Studio Instant Run Issue

Whenever I hit 'Instant Run' icon without any modification to source code, I get 2-3 min avg build time with a message Instant Run applied code changes and restarted the app. Field Type Change. I printed how long every task took using this and pasted my logs here. I have highlighted the tasks that...
M-WaJeEh
2

votes
1

answer
876

views

Prevent dialog from taking up whole width of screen in landscape mode - Android

I have a custom dialog that contains long text. In portrait mode dialog looks good. But in landscape mode I don't want it to take up whole screen width. Is there any way to define max width of a dialog in % of screen's width? Because wrap_content won’t work in this case. Any solution?
M-WaJeEh
2

votes
1

answer
3.2k

views

Server Google App Engine (1.8.2) at localhost failed to start

I am trying to create Dynamic Web Application in Eclipse on Google App Engine. I have followed this tutorial exactly but whenever I Run on Server, I get the following error. I have shown both, error log and the dialog that appears when I run my project. And apparently there is no search result after...
M-WaJeEh
1

votes
2

answer
4k

views

PowerManager.PARTIAL_WAKE_LOCK android

I am very confused whether to acquire this wakelock. E.g. I have this type of code that is called from onReceive() of a BroadcastReceiever (CONNECTIVITY_CHANGE, BOOT_COMPLETED etc) asynchronously i.e. I am launching an IntentService from onReceive() which performs heavy lifting. private static void...
M-WaJeEh
4

votes
1

answer
444

views

Custom fonts for TextView based on languages inside String

I have two font ttf files that must be applied on a TextView based on languages inside String. So e.g. consider this sample text: hey what's up ضعيف I can just apply a typeface span based on language but it requires custom markup in every string that is fetched from our server e.g. hey what's u...
M-WaJeEh
6

votes
1

answer
3.2k

views

ConstraintLayout issue with horizontal weight

Consider following xml layout: which produces this layout which is what I want: But if I mark B3 as gone then B1's width is set to 0 and B2 move to left. Whereas I want B2 to take B3's place and B1 to expand: Any idea what I might be doing wrong?
M-WaJeEh
76

votes
17

answer
213.4k

views

java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

I am trying to build a simple hello world application for two days using Jersey + Google app engine. For simple AppEngine project I followed these tutorials and both works just fine https://developers.google.com/appengine/docs/java/gettingstarted/creating https://developers.google.com/appengine/docs...
M-WaJeEh
2

votes
0

answer
881

views

InvalidKeyException: Only SecretKey is supported

I have recently started seeing this error in devices. java.security.InvalidKeyException: Only SecretKey is supported at com.android.org.conscrypt.OpenSSLCipher.checkAndSetEncodedKey(OpenSSLCipher.java:436) at com.android.org.conscrypt.OpenSSLCipher.engineInit(OpenSSLCipher.java:273) at javax.crypto....
M-WaJeEh
4

votes
2

answer
2.4k

views

Fill Sine Graph Android

I have this code: public class TestView extends View { private Path mPath; private Paint mPaint = new Paint(); public TestView(Context context) { this(context, null); } public TestView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public TestView(Context context, AttributeSet att...
M-WaJeEh
15

votes
2

answer
2.2k

views

Resources$NotFoundException on Samsung

One of my app is crashing on Samsung S5 (SM G900V to be precise) with this exception: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/common_signin_btn_icon_disabled_focus_light.9.png from drawable resource ID #0x7f0200e5 at android.content.res.Resources$CRunnable_openmp...
M-WaJeEh
4

votes
1

answer
529

views

Regex not working in Android but works fine in Java

I have the following code: String compact = Pattern.compile(' *(\\{) *| *(\\}) *').matcher(' { { } } ') .replaceAll('$1$2'); In Java, compact contains {{}} - which is what I want - but on Android, I am getting {null{nullnull}null} which is making me crazy. Am I doing something wrong? Following lin...
M-WaJeEh
5

votes
1

answer
683

views

Strange behaviour of `drawTextOnPath()` with hardware accelration

In hardware accelerated custom View added in ScrollView or ListView both of the following code snippets produces same result: (please ignore best practises for a sec) @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // centering stuff float centerX = getWidth() / 2f; float cen...
M-WaJeEh
6

votes
1

answer
4.1k

views

android:theme not working in layout file

According to this: Elements in XML layout definitions can specify the android:theme attribute, which references a theme resource. This attribute modifies the theme for the element and any child elements, which is useful for altering theme color palettes in a specific portion of an interface. Which m...
M-WaJeEh
3

votes
3

answer
4.2k

views

Simple fade-out animation for a string on canvas, android

I have a custom view extending from View with lots of text drawn at different angles and I want a particular string to decrease its alpha value to a certain level once, after first start. Any suggestion or snippet would be appreciated :) postInvalidateDelayed(...) doesn't seem to work for this task.
M-WaJeEh