call activity method from broadcast receiver

In the main activity, a layout is loaded that has some input fields and a submit button. When the submit button is clicked, the onClick handler method sends an sms back to the same mobile number : SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(number, null, “hi”, null, null); There is a broadcast receiver defined that intercepts the […]

When are child views added to Layout/ViewGroup from XML

My question is : I want to know when does a xLayout (or ViewGroup in general) add a child view from XML ? And by “when” I mean at what point of code, in what “pass” of the “traversal” of the UI toolkit ? Which method of xLayout or ViewGroup should I override ? I […]

Retrieving view name property in android?

Is there anyway to retrieve the name of a view in android? Have been walking through the api and haven’t seen any method to do this.

Android transparent text

I need to display a TextView over a gradient background. The TextView itself should have a plain white background, and the text should be transparent. However, setting a transparent color (#00000000) to the text doesn’t work: it only shows a white rectangle, the background doesn’t show up where the text is (the text takes the […]

OTP (token) should be automatically read from the message

I am working on an Android App, in which server sends an OTP and the user needs to enter this OTP in the App, to SignUp for my App. What I want is, that my App should be able to automatically read the OTP sent by the server. How can I achieve this? Any help […]

Java, HttpURLConnection and setting the content length

I’m setting the length of the content in my HttpURLConnection, for a PUT. urlConnection.setRequestProperty(“Content-Length”, “” + responseJSONArray.toString(2).getBytes(“UTF8”).length); The actual number of bytes is 74. However, when I query the content length of urlConnection I’m returned -1. Why is that? And why are lengths not equal (given that I set this)? I must set the content-length […]

Override Java version when building a Cordova project with gradle

I am trying to build a Cordova project using gradle as a build tool. In the Cordova project I have my own plugin that requires Java 1.7. In the build.gradle that comes with Cordova the java version is 1.6. build.gradle: android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_6 } } The build.gradle comes with a […]

/dev/log/main not found

I’m trying to develop an Android application but when I try to connect to logcat I get the following error: Unable to open log device ‘/dev/log/main’: No such file or directory I already installed a new SDK, rebooted my phone… nothing seems to solve the problem. Anyone has any solution? Samsung Galaxy S (Darky’s v9.1) […]

ValueEventListener vs ChildEventListener for RecyclerView in Android

Firebase Database users know that there are two basic listeners for listening Data: ValueEventListener and ChildEventListener. It works great when we listen for one object, but becomes quite difficult when we listen for some collection. To specify question, let’s imagine that we have HackerNews feed, and we listen e.g. “posts” object in Firebase. Of course […]

Photo capture Intent causes NullPointerException on Samsung phones only

Photo capture Intent causes NullPointerException on Samsung phones only. Implementation below. final Button capture = (Button)findViewById(R.id.capture_button); capture.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); } }); protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_PIC_REQUEST) { Bitmap thumbnail […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.