jeudi 28 mai 2015

App crashes when loading image from gallery

In my app ,i have two buttons ,one for loading the image from gallery(from device )and another one for taking pictures by accesing the camera of the device,My code is working properly on some devices ,bt in some devices ,the app crashes when clicking an image in the gallery.Can anybody help me to find out the actual propblem??

public class MainActivity extends ActionBarActivity {
private static int RESULT_LOAD_IMAGE = 1;
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button buttonLoadImage = (Button) findViewById(R.id.buttonLoadPicture);
    buttonLoadImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {

            Intent i = new Intent(
                    Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

            startActivityForResult(i, RESULT_LOAD_IMAGE);
        }
    });
    this.imageView = (ImageView)this.findViewById(R.id.imgView);
    Button photoButton = (Button) this.findViewById(R.id.button2);
    photoButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, CAMERA_REQUEST);
        }
    });
}

And the xml is

<LinearLayout xmlns:android="http://ift.tt/nIICcg" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:id="@+id/imgView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"></ImageView>
<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/black" >
<Button android:id="@+id/buttonLoadPicture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:layout_weight="0"
    android:text="Load Picture"
    android:layout_gravity="center"></Button>
    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Take Picture"
        android:layout_alignParentRight="true"/>

</RelativeLayout>

Android won't stop GPS intent

I want to ask for the GPS location, even when the app is in the background. Therefore I used a PendingIntent as follows:

final Intent intent = new Intent(this, LocationReceiver.class);
mLocationIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, mLocationIntent);

It works great. However, the GPS location is still updating, even when the MainActivity is destroyed. The Intent Service won't stop. I tried to stop the Intent in the onDestroyed method of the MainActivity like this:

@Override
protected void onDestroy() {
    LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, mLocationIntent);
}

...but this method won't get called.

How can I stop the Intent when the MainActivity is destroyed?

Why do we need Intents for transition to new Activity/Service?

I was asked the following question in an interview :

Why do we need Intents to start new Activity or Service? Alternatively, why don't we start Activity by creating a new object and calling activity_obj.onCreate(..); on it.

I could count the benefits of intents like transferring data and intent-filters targeting appropriate activities, but except that I couldn't come up with a satisfying answer.

Is it related to life cycle callback handling of Activities ? I can't find a good answer anywhere. Please suggest!!

Share Texts to Whats up using Intent, Whats up is not finish after share Text sucessfully,and not return back to my app

this is my code.

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent,getResources().getText(R.string.send_to)));

when choose share app whats up, after share text ,i can not return to my app.

FullScreenIntent only appears if I clear the notification

I'm trying to launch a FullScreenIntent from a service working in the background, but I realised that the intent would not be shown another time if I do not clear the notification from the task bar. I have tried removing the notification by removing

.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notification")
.setContentText("A client is calling")

but that just removes my option of clearing the notification. Can somebody help?

My code is as shown:

                    NotificationCompat.Builder mBuilder =
                            new NotificationCompat.Builder(this)
                                    .setSmallIcon(R.drawable.ic_launcher)
                                    .setContentTitle("Notification")
                                    .setContentText("A client is calling")
                                    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                                    .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
                                    .setAutoCancel(true);
                    Intent resultIntent = new Intent(this, MainActivity.class);
                    String strName = ((String) message).substring(9);
                    resultIntent.putExtra("Msg",strName);
    // Because clicking the notification opens a new ("special") activity, there's
    // no need to create an artificial back stack.
                    PendingIntent resultPendingIntent =
                            PendingIntent.getActivity(
                                    this,
                                    0,
                                    resultIntent,
                                    PendingIntent.FLAG_CANCEL_CURRENT
                            );

                    mBuilder.setFullScreenIntent(resultPendingIntent,true);
                    int mNotificationId = 001;
    // Gets an instance of the NotificationManager service
                    NotificationManager mNotifyMgr =
                            (NotificationManager)this.getSystemService(this.NOTIFICATION_SERVICE);
    // Builds the notification and issues it.
                    Notification m = mBuilder.build();
                    m.flags = Notification.FLAG_AUTO_CANCEL;
                    mNotifyMgr.notify(mNotificationId, m);

Not able to launch device administrator activity from my service class (Android Lollipop)

I'm trying to prompt the user with the device administrator activity to enable my application as a device administrator. And here is the code which attempts to call the device administrator activity from my service class:

ComponentName deviceAdmin=new ComponentName(context,DeviceAdminReceiver.class);
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Make sure to accept in order to provide support for lock and wipe");
PendingIntent pendingIntent = PendingIntent.getActivity(context, DevicePolicyManagerLockWipeService.RESULT_ENABLE, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
pendingIntent.send();

Android Manifest is as follows;

<receiver android:name=".DeviceAdminReceiver" android:label="DeviceAdminReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN" android:exported="true">
<meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin"/>
<intent-filter>
   <action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
</intent-filter>
</receiver>

This works perfectly on any 4.x android versions, but doesn't work on Lollipop version. In lollipop when I kick start my application it looks like it is opening the device admin activity, but immediately the activity animation stops and it closes without prompting the user to enable device admin. However, my application shows up in the settings->security->device administratior window, but it is unchecked as a device admin.

mercredi 27 mai 2015

How do I get a video from URI and compress it and convert it into base64 and send it to the server on Android?

I want to capturing video and sending it to the server in base64. Before sending it, I want to check the video length and video size. I am able to capture the video

        switch (v.getId()) {
            case R.id.camera_button:
                intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                if (intent.resolveActivity(getPackageManager()) != null) {
                    startActivityForResult(intent, INTENT_VIDEO);
                }
                break;
            }
        }

and get the URI

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == INTENT_VIDEO && resultCode == RESULT_OK) {
            Uri uri = data.getData();
            videoView.setVideoURI(uri);
            videoView.start();
        }
    }

I am able to get a video path

    private String getPath(Uri video) {
        String path = video.getPath();
        String[] projection = {MediaStore.Video.Media.DATA};
        Cursor cursor = getContentResolver().query(media, projection, null, null, null);
        if (cursor.moveToFirst()) path = cursor.getString(cursor.getColumnIndexOrThrow(projection[0]));
        cursor.close();

        return path;
    }

How do I get a video object from that path so that I could compress, check video duration, file size? For image, it will be as simple as this BitmapFactory.decodeFile(photoPath);

and after that, I would like to convert it to base64. For image, it's as simple as this

    private String toBase64(Bitmap bitmap) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 60, outputStream);
        byte[] bytes = outputStream.toByteArray();

        return Base64.encodeToString(bytes, Base64.DEFAULT);
    }

Currently I am doing like this

    private String toBase64(Uri video) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            String path = getPath(video);
            File tmpFile = new File(path);
            BufferedInputStream in = new BufferedInputStream(new FileInputStream(tmpFile));
            long length = tmpFile.length();
            int inLength = (int) length;
            byte[] b = new byte[inLength];
            int bytesRead;
            while ((bytesRead = in.read(b)) != -1) {
                baos.write(b, 0, bytesRead);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        return Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);
    }

I get the base64, though I don't know if it's the correct one. but, I could not check video size, duration, etc. and also when I try to send the base64 to the server, I get error Unexpected response code 500.

I Want to Make Gif(Animation) File As Live Wallpaper in android Or Make Walllaper That Change Wallpaper Auto Meticly

  • I want to create Application as Like Live Wallpaper I Want to change Wallpaper One By One In Some Particuler Time Or I Want To Use .gif file As Auto Change Wallpaper

Start Activity from RecycleView Adapter on click

I have an issue starting a new activity from a CardView Adapter, this is the code:

RVAdapter adapter = new RVAdapter(array_restaurants);
recList.setAdapter(adapter);

And after in the adapter. I set an OnClickListener

personName.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Context context = v.getContext();
                System.out.println("Context");
                System.out.println(context.toString());
                Intent intent = new Intent(v.getContext(), Restaurante.class);
                v.getContext().startActivity(intent);
            }
        });

When i print the context in the console everything looks fine, but after the aplication stop working. Why?

Thank you very much.

How to connect an intent to a function

I don't see how to specify the function that an intent filter calls or how to get the arguments (data) from that intent.

For instance, say in my AndroidManifest.xml file I have the following:

<intent-filter>
     <action android:name="android.intent.action.VIEW"></action>
     <category android:name="android.intent.category.DEFAULT"></category>
     <category android:name="android.intent.category.BROWSABLE"></category>
     <data android:host="example.com" android:scheme="http"></data>
</intent-filter>

A user goes to http://ift.tt/1HMV2Mh - an app-chooser pops up and the user chooses my app (let's call it MyApp). So what gets called within MyApp and how do I get the arguments, in this case /some-end-point that was called?

How do I specify what block of code this intent refers to ... Do I register it within the Java code or do I specify it in the XML?

Sorry for the basic question but I've been unable to find this after quite literally days of searching and going through the sample code.

hide an android app after install and launch it from another app

Hello someone can help me.First of all, sorry i'm from Afghanistan and my English is not good.This translated by Google. I want to write the two programs.

1_ the first program should hide Automatically from launcher after installation

2_ the second program have a button that when clicked launch & run first program.Indeed it's a launcher for first program that Sets setting then launch.

3- how install this two program with one apk.

please tell me how do it. thanks Beforehand.

List fragment not disappearing

Based on my code whenever I run my app and click a list item, the intended fragment does appear but the list fragment does not disappear from view (see attached screenshot). What needs to be done in order to remove the list from the user's view?

    FragmentItem1 newFragment = new FragmentItem1();
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    transaction.replace(R.id.master_container, newFragment);                         

transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    transaction.addToBackStack(null);
    transaction.commit();

enter image description here

Unable to get the Contacts in HTC devices

I'm getting contacts from the ContactPicker from various devices but While trying to fetch contact from HTC devices I'm gettting the below exception :

java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.HtcContactsProvider2 uri content://com.android.contacts/data/719 from pid=8344, uid=10214 requires android.permission.READ_CONTACTS, or grantUriPermission()

Permissions that I have given is:

android.permission.READ_CONTACTS

Below is the code that I have implemented:

Intent intent = new Intent(Intent.ACTION_PICK,
                        Phone.CONTENT_URI);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
                startActivityForResult(intent, 101);


@Override
    protected void onActivityResult(int arg0, int arg1, Intent arg2) {
        // TODO Auto-generated method stub
        super.onActivityResult(arg0, arg1, arg2);

        if (arg1 == Activity.RESULT_OK) {
            Uri contactData = arg2.getData();
            ContentResolver cur = getContentResolver();
            Cursor cursorID = getContentResolver().query(contactData,
                    new String[] { ContactsContract.Contacts._ID }, null, null,
                    null);

            grantUriPermission("ContactsContract.CommonDataKinds.Phone.CONTENT_URI", contactData, 2);
            Cursor c = cur.query(contactData, null, null, null, null);
            if (c.moveToFirst()) {
                String name = c
                        .getString(c
                                .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

                String number = c
                        .getString(c
                                .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

                Toast.makeText(getApplicationContext(),
                        "" + name + " " + number, 4000).show();

            }
        }

    }

Any help is appreciated.

Cannot share images to WeChat and Line using ACTION_SEND intent

My code is as below -

 Intent prototype = new Intent(Intent.ACTION_SEND);
 prototype.setData(uri);   // uri is of the image file
 prototype.setType(image/*);
 prototype.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

 prototype.putExtra(Intent.EXTRA_STREAM, uri); 

List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
       if (!resInfo.isEmpty()) 
       { 
           for (ResolveInfo resolveInfo : resInfo) 
            {
                if (resolveInfo.activityInfo == null)  
                {
                    continue; 
                }

                // Retrieve the package name and class name to populate the chooser intent
                Intent intent = (Intent) prototype.clone();
                String packageName = resolveInfo.activityInfo.packageName;
                intent.setPackage(packageName); 
                intent.setClassName(packageName, resolveInfo.activityInfo.name); 
            targetedIntents.add(intent);
        }}
            Intent chooserIntent = Intent.createChooser(topIntents.remove(targetedIntents.size() - 1), chooserTitle); 
                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedIntents.toArray(new Parcelable[] {})); 

When I select WeChat and Line app from the chooser, nothing happens. Line app just displays an error that it is unable to share. WeChat doesn't give any message. Sharing works fine on Whatsapp and Hangouts using my code.

We can share images on WeChat and Line from Gallery. How does that work? Is it not a Send action intent?

Qt for Android - startActivityForResult equivalent does not work

There are poorly documented features in Qt for Android - we can use Intent features by JNI (Java Native Interface). There are some examples with startActivity equivalent, but I did not find any with result receiving.

Here's Java code with ilustration what I want to do:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
getActivity().startActivityForResult(intent, 1);

I used documentation to write equivalent in Qt:

QAndroidJniObject ACTION_GET_CONTENT = QAndroidJniObject::getStaticObjectField<jstring>("android/content/Intent", "ACTION_GET_CONTENT");
QAndroidJniObject intent("android/content/Intent");
if (ACTION_GET_CONTENT.isValid() && intent.isValid()) {
    intent.callObjectMethod("setAction", "(Ljava/lang/string;)V", ACTION_GET_CONTENT.object<jstring>());
    intent.callObjectMethod("setType", "(Ljava/lang/string;)V", QAndroidJniObject::fromString("file/*").object<jstring>());
    QtAndroid::startActivity(intent, EXISTING_FILE_NAME_REQUEST, receiver);
    return true;
} else {
    return false;
}

receiver is a pointer to object of class, which extends abstract class QAndroidActivityResultReceiver. Here's it's implementation of virtual function handleActivityResult:

void MyReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data)
{
    jint RESULT_OK = QAndroidJniObject::getStaticField<jint>("android/app/Activity", "RESULT_OK");
    if (receiverRequestCode == EXISTING_FILE_NAME_REQUEST && resultCode == RESULT_OK) {
        QString path = data.callObjectMethod("getData", "()Landroid/net/Uri;").callObjectMethod("getPath", "()Ljava/lang/String;").toString();
        _dialog->emitExistingFileNameReady(path);
    } else {
        _dialog->emitExistingFileNameReady(QString());
    }
}

Something is wrong with my code, because when I run it, following error messages appears (and program is being aborted):

F/art     ( 6837): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception 'android.content.ActivityNotFoundException' thrown in unknown throw location
F/art     ( 6837): art/runtime/check_jni.cc:65]     in call to NewGlobalRef
F/art     ( 6837): art/runtime/check_jni.cc:65] "QtThread" prio=5 tid=15 Runnable
F/art     ( 6837): art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x12e75100 self=0xaec43400
F/art     ( 6837): art/runtime/check_jni.cc:65]   | sysTid=6882 nice=0 cgrp=default sched=0/0 handle=0xb491b780
F/art     ( 6837): art/runtime/check_jni.cc:65]   | state=R schedstat=( 0 0 0 ) utm=39 stm=20 core=0 HZ=100
F/art     ( 6837): art/runtime/check_jni.cc:65]   | stack=0xa2b04000-0xa2b06000 stackSize=1012KB
F/art     ( 6837): art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #00 pc 00004e64  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #01 pc 00003665  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #02 pc 00256429  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+84)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #03 pc 00238fe7  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+158)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #04 pc 000b191b  /system/lib/libart.so (art::JniAbort(char const*, char const*)+610)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #05 pc 000b2055  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #06 pc 000b530f  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1346)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #07 pc 000b66cd  /system/lib/libart.so (art::CheckJNI::NewGlobalRef(_JNIEnv*, _jobject*)+28)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #08 pc 001ea0a7  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::QJNIObjectPrivate(_jobject*)+82)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #09 pc 001ea69d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #10 pc 001ec719  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::getStaticObjectField(char const*, char const*, char const*)+48)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #11 pc 0017718d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #12 pc 00177a3d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::writableLocation(QStandardPaths::StandardLocation)+860)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #13 pc 0017841f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::standardLocations(QStandardPaths::StandardLocation)+790)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #14 pc 00013e5b  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (ApplicationController::openFileButtonClicked()+130)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #15 pc 001cce4f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QMetaObject::activate(QObject*, int, int, void**)+394)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #16 pc 00261987  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::clicked(bool)+26)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #17 pc 001460f9  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #18 pc 001468f7  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #19 pc 00146979  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::mouseReleaseEvent(QMouseEvent*)+88)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #20 pc 0019d509  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::mouseReleaseEvent(QMouseEvent*)+4)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #21 pc 00100bbd  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QWidget::event(QEvent*)+536)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #22 pc 0019d57d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::event(QEvent*)+50)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #23 pc 000e2a41  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #24 pc 000e5583  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+1382)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #25 pc 001ae40f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #26 pc 000e4d5b  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool)+286)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #27 pc 0010a19b  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #28 pc 0010a8d3  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #29 pc 000e2a41  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #30 pc 000e5e53  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+3638)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #31 pc 001ae40f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #32 pc 000a09cd  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*)+516)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #33 pc 000a06ed  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent*)+3492)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #34 pc 000a1b13  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*)+382)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #35 pc 00093181  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)+20)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #36 pc 00028135  /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #37 pc 001ad533  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+14)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #38 pc 001adc13  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+226)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #39 pc 001b2527  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::exec()+82)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #40 pc 00012a41  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (main+48)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #41 pc 000190b5  /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #42 pc 00016baf  /system/lib/libc.so (__pthread_start(void*)+30)
F/art     ( 6837): art/runtime/check_jni.cc:65]   native: #43 pc 00014af3  /system/lib/libc.so (__start_thread+6)
F/art     ( 6837): art/runtime/check_jni.cc:65]   (no managed stack frames)
F/art     ( 6837): art/runtime/check_jni.cc:65] 
F/art     ( 6837): art/runtime/runtime.cc:289] Runtime aborting...
F/art     ( 6837): art/runtime/runtime.cc:289] Aborting thread:
F/art     ( 6837): art/runtime/runtime.cc:289] "QtThread" prio=5 tid=15 Native
F/art     ( 6837): art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x12e75100 self=0xaec43400
F/art     ( 6837): art/runtime/runtime.cc:289]   | sysTid=6882 nice=0 cgrp=default sched=0/0 handle=0xb491b780
F/art     ( 6837): art/runtime/runtime.cc:289]   | state=R schedstat=( 0 0 0 ) utm=42 stm=20 core=0 HZ=100
F/art     ( 6837): art/runtime/runtime.cc:289]   | stack=0xa2b04000-0xa2b06000 stackSize=1012KB
F/art     ( 6837): art/runtime/runtime.cc:289]   | held mutexes= "abort lock" "mutator lock"(shared held)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #00 pc 00004e64  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #01 pc 00003665  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #02 pc 00256429  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+84)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #03 pc 00238fe7  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+158)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #04 pc 0022881d  /system/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*)+32)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #05 pc 00228abf  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+410)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #06 pc 00228c7f  /system/lib/libart.so (art::Runtime::Abort()+82)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #07 pc 000a7371  /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #08 pc 000b1b17  /system/lib/libart.so (art::JniAbort(char const*, char const*)+1118)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #09 pc 000b2055  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #10 pc 000b530f  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1346)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #11 pc 000b66cd  /system/lib/libart.so (art::CheckJNI::NewGlobalRef(_JNIEnv*, _jobject*)+28)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #12 pc 001ea0a7  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::QJNIObjectPrivate(_jobject*)+82)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #13 pc 001ea69d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #14 pc 001ec719  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::getStaticObjectField(char const*, char const*, char const*)+48)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #15 pc 0017718d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #16 pc 00177a3d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::writableLocation(QStandardPaths::StandardLocation)+860)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #17 pc 0017841f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QStandardPaths::standardLocations(QStandardPaths::StandardLocation)+790)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #18 pc 00013e5b  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (ApplicationController::openFileButtonClicked()+130)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #19 pc 001cce4f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QMetaObject::activate(QObject*, int, int, void**)+394)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #20 pc 00261987  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::clicked(bool)+26)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #21 pc 001460f9  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #22 pc 001468f7  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #23 pc 00146979  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QAbstractButton::mouseReleaseEvent(QMouseEvent*)+88)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #24 pc 0019d509  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::mouseReleaseEvent(QMouseEvent*)+4)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #25 pc 00100bbd  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QWidget::event(QEvent*)+536)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #26 pc 0019d57d  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QToolButton::event(QEvent*)+50)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #27 pc 000e2a41  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #28 pc 000e5583  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+1382)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #29 pc 001ae40f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #30 pc 000e4d5b  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool)+286)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #31 pc 0010a19b  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #32 pc 0010a8d3  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #33 pc 000e2a41  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplicationPrivate::notify_helper(QObject*, QEvent*)+104)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #34 pc 000e5e53  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Widgets.so (QApplication::notify(QObject*, QEvent*)+3638)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #35 pc 001ae40f  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::notifyInternal(QObject*, QEvent*)+62)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #36 pc 000a09cd  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*)+516)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #37 pc 000a06ed  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent*)+3492)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #38 pc 000a1b13  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*)+382)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #39 pc 00093181  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Gui.so (QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)+20)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #40 pc 00028135  /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #41 pc 001ad533  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+14)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #42 pc 001adc13  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+226)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #43 pc 001b2527  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libQt5Core.so (QCoreApplication::exec()+82)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #44 pc 00012a41  /data/app/org.qtproject.example.TouchImage-2/lib/arm/libTouchImage.so (main+48)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #45 pc 000190b5  /data/data/org.qtproject.example.TouchImage/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #46 pc 00016baf  /system/lib/libc.so (__pthread_start(void*)+30)
F/art     ( 6837): art/runtime/runtime.cc:289]   native: #47 pc 00014af3  /system/lib/libc.so (__start_thread+6)
F/art     ( 6837): art/runtime/runtime.cc:289]   (no managed stack frames)
F/art     ( 6837): art/runtime/runtime.cc:289] Pending exception android.content.ActivityNotFoundException thrown by 'unknown throw location'
F/art     ( 6837): art/runtime/runtime.cc:289] android.content.ActivityNotFoundException: No Activity found to handle Intent {  }
F/art     ( 6837): art/runtime/runtime.cc:289]   at void android.app.Instrumentation.checkStartActivityResult(int, java.lang.Object) (Instrumentation.java:1781)
F/art     ( 6837): art/runtime/runtime.cc:289]   at android.app.Instrumentation$ActivityResult android.app.Instrumentation.execStartActivity(android.content.Context, android.os.IBinder, android.os.IBinder, android.app.Activity, android.content.Intent, int, android.os.Bundle) (Instrumentation.java:1501)
F/art     ( 6837): art/runtime/runtime.cc:289]   at void android.app.Activity.startActivityForResult(android.content.Intent, int, android.os.Bundle) (Activity.java:3745)
F/art     ( 6837): art/runtime/runtime.cc:289]   at void android.app.Activity.startActivityForResult(android.content.Intent, int) (Activity.java:3706)
F/art     ( 6837): art/runtime/runtime.cc:289] Dumping all threads without appropriate locks held: thread list lock mutator lock
F/art     ( 6837): art/runtime/runtime.cc:289] All threads:
F/art     ( 6837): art/runtime/runtime.cc:289] DALVIK THREADS (16):
F/art     ( 6837): art/runtime/runtime.cc:289]   (no managed stack frames)
<< lot more lines of log here >>
F/libc    ( 6837): Fatal signal 6 (SIGABRT), code -6 in tid 6882 (QtThread)

This occures after QtAndroid::startActivity and before MyReceiver::handleActivityResult (debugger says so). What is more, there are warnings/errors during program starts, but it does not cause program abborting:

W/linker  ( 4449): libQt5Gui.so: unused DT entry: type 0x1d arg 0x4c19d
W/linker  ( 4449): libQt5Widgets.so: unused DT entry: type 0x1d arg 0x6a769
W/linker  ( 4449): libQt5Svg.so: unused DT entry: type 0x1d arg 0x8f18
W/linker  ( 4449): libQt5AndroidExtras.so: unused DT entry: type 0x1d arg 0x5044
W/linker  ( 4449): libqtforandroid.so: unused DT entry: type 0x1d arg 0x8cac
I/Qt      ( 4449): qt start
W/System.err( 4449): java.lang.NoSuchFieldException: mInsetState
W/System.err( 4449):    at java.lang.Class.getDeclaredField(Class.java:890)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getAccessibleField(ExtractStyle.java:405)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1103)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getLayerDrawable(ExtractStyle.java:629)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getRippleDrawable(ExtractStyle.java:820)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1028)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.extractViewInformations(ExtractStyle.java:1187)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.extractTextAppearanceInformations(ExtractStyle.java:1336)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.<init>(ExtractStyle.java:2017)
W/System.err( 4449):    at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:438)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449):    at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:245)
W/System.err( 4449):    at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:655)
W/System.err( 4449):    at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:895)
W/System.err( 4449):    at android.app.Activity.performCreate(Activity.java:5990)
W/System.err( 4449):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
W/System.err( 4449):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
W/System.err( 4449):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
W/System.err( 4449):    at android.app.ActivityThread.access$800(ActivityThread.java:151)
W/System.err( 4449):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
W/System.err( 4449):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 4449):    at android.os.Looper.loop(Looper.java:135)
W/System.err( 4449):    at android.app.ActivityThread.main(ActivityThread.java:5254)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
W/System.err( 4449):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
W/System.err( 4449): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1103)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getLayerDrawable(ExtractStyle.java:629)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getRippleDrawable(ExtractStyle.java:820)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.getDrawable(ExtractStyle.java:1028)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.extractViewInformations(ExtractStyle.java:1187)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.extractTextAppearanceInformations(ExtractStyle.java:1336)
W/System.err( 4449):    at org.qtproject.qt5.android.ExtractStyle.<init>(ExtractStyle.java:2017)
W/System.err( 4449):    at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:438)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449):    at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:245)
W/System.err( 4449):    at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:655)
W/System.err( 4449):    at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:895)
W/System.err( 4449):    at android.app.Activity.performCreate(Activity.java:5990)
W/System.err( 4449):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
W/System.err( 4449):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
W/System.err( 4449):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
W/System.err( 4449):    at android.app.ActivityThread.access$800(ActivityThread.java:151)
W/System.err( 4449):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
W/System.err( 4449):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 4449):    at android.os.Looper.loop(Looper.java:135)
W/System.err( 4449):    at android.app.ActivityThread.main(ActivityThread.java:5254)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4449):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 4449):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
W/System.err( 4449):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
<< more lines of log here >>
W/linker  ( 4449): libTouchImage.so: unused DT entry: type 0x1d arg 0x8efc
W/Qt A11Y ( 4449): Could not activate platform accessibility.

Want to access notifications from all apps inside my app.Is it possible in android?

I want to make an app where I can access all the notifications which comes to the notification center. Any help will be appreciated.

Please suggest some blog or article.I didn't find any useful info.

Thanks in advance.

Android sending extra's with pending Intent

For my push notifications, I am sending some data which I will then choose which fragment I want to open. I am trying to do this by adding an Intent Extra to the Pending Intent but whenever I try to use this extra in the next Activity, it returns NULL.

I have read here I need to change the PendingActivity flag, but I have changed it a few times and made no difference. I must be making a silly mistake somewhere.

    private void sendNotification(String title, String msg, String fragment) {
    mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.logo_m_white)
//          .setLargeIcon(((BitmapDrawable) getResources().getDrawable(R.drawable.icon_filled_m)).getBitmap())
            .setContentTitle(title)
            .setContentText(msg)
            .setSound(Uri.EMPTY)
            .setPriority(1)
            .setLights(Color.RED, 300, 5000)
            .setAutoCancel(true);
    Intent intent = new Intent(this, LoginActivity.class);
    intent.putExtra("fragment", fragment);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pi = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);
    mBuilder.setContentIntent(pi);
    mNotificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(0, mBuilder.build());
}

How to handle multiple intent actions in android notification alarm

my query is that i am trying to redirect the notification intent different depending on the conditions ,Am working on the alarm system where i need to redirect the notification intent to some activity say A if the user clicks it during the alarm playing and on completion the notification should be redirected to some other activity if still available there. here is my code

   private void DisplayNotification(String AlarmName, Context context) {
    // Context context = context.getApplicationContext();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Intent mIntent;
    SharedPreferences alarmindicator = context.getSharedPreferences(
            "notifyintent", context.MODE_PRIVATE);
    int code;
    SharedPreferences.Editor editor = alarmindicator.edit();
    if (alarmindicator.getBoolean("notifyintentPlaying", true)) {
        mIntent = new Intent(context, AlarmAlertActivity.class);
        Toast.makeText(context, "inalmact", 0).show();
        code = 1;
    }

    else {
        editor.putBoolean("notifyintentPlaying", true);
        editor.commit();
        mIntent = new Intent(context, MainActivity.class);
        // AlarmAlertActivity.this.finish();
        code = 2;
        Toast.makeText(context, "in main act", 0).show();

    }

    Bundle bundle = new Bundle();

    bundle.putString("test", "test");
    mIntent.putExtras(bundle);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, code,
            mIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    Resources res = context.getResources();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(
            context);

    builder.setContentIntent(pendingIntent)
            .setSmallIcon(R.drawable.notifyiconlarg)
            .setLargeIcon(
                    BitmapFactory.decodeResource(res,
                            R.drawable.notifyiconlarg))
            // .setTicker(res.getString(R.string.notification_title))
            .setTicker(AlarmName).setAutoCancel(true)
            .setContentTitle(AlarmName)
            .setContentText("Time to offer " + AlarmName + " Prayers");

    notificationManager = (NotificationManager) context
            .getSystemService(context.NOTIFICATION_SERVICE);

    notificationManager.notify(123, builder.build());
}

How to set two intents in a pending intent

Is possible to set more than one intent for be launched when, in example, the user clicks an notification.

Let me explain my concrete problem:

I have an app with notifications. Each notification open a different Activity (with different extras too).

Now I want to extract info about the notifications usage. So, every time a notification gets open I'd like to launch a Service with some extras.

I'd like to implement that without modifying the existing activities, since they are not "guilty" of the change.

Ideally the pseudocode could be something like that:

Intent originalActivityIntent=...;
Intent notificationsAnalyticsIntent=getRegisterNotificationClick(notificationId,username);
PendingIntent pi= PendingIntent.multiple(
                                   context,
                                   originalActivityIntent,
                                   notificationsAnalyticsIntent)

Having both intents launched when the notification is clicked.

Writting some kind of service/broadcast receiver could be pretty complex since I would need to handle the different params for each Activity.

Any ideas of how to keep this clean?

Passing Arraylist of objects through intent

Hi I am working on an application and trying to pass list of objects (IntentBinders) from MainActivity to RouteSummary class but the application crashes with exception.

public class IntentBinder implements Serializable {
    public String rtName;
    public double rtDistance;
    public int rtfare;
}

MainActivity:

Intent passIntent  = new Intent(getApplicationContext(),RouteSummary.class);
IntentBinder obj1 = new IntentBinder();
                        obj1.rtName = finalRt1Name;
                        obj1.rtDistance = distanceRt1;
                        obj1.rtfare = fareRt1;
                        IntentBinder obj2 = new IntentBinder();
                        obj2.rtName = finalRt2Name;
                        obj2.rtDistance = distanceRt2;
                        obj2.rtfare = fareRt2;
                        ArrayList<IntentBinder> list = new ArrayList<IntentBinder>();
                        list.add(obj1);
                        list.add(obj2);
                        Bundle bundleObj = new Bundle();
                        bundleObj.putSerializable("key", list);
                        passIntent.putExtras(bundleObj);
                        startActivity(passIntent);

RouteSummary.Java(Recieving Activity)

setContentView(R.layout.route_summary);

        try{
            // Get thIne Bundle Object        
            Bundle bundleObject = getIntent().getExtras();

                // Get ArrayList Bundle
            ArrayList<IntentBinder> classObject = (ArrayList<IntentBinder>) bundleObject.getSerializable("key");


            for(int index = 0; index < classObject.size(); index++){

                IntentBinder Object = classObject.get(index);
                Toast.makeText(getApplicationContext(), "Id is :"+Object.rtName, Toast.LENGTH_SHORT).show();
            }
        } catch(Exception e){
            e.printStackTrace();
        }

LogCat:

05-27 14:36:50.697: E/AndroidRuntime(31484): FATAL EXCEPTION: main
05-27 14:36:50.697: E/AndroidRuntime(31484): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.webmonopolists.project_linx/com.webmonopolists.project_linx.RouteSummary}: java.lang.NullPointerException
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1734)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1753)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.app.ActivityThread.access$1500(ActivityThread.java:155)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:999)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.os.Handler.dispatchMessage(Handler.java:130)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.os.Looper.loop(SourceFile:351)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.app.ActivityThread.main(ActivityThread.java:3820)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at java.lang.reflect.Method.invokeNative(Native Method)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at java.lang.reflect.Method.invoke(Method.java:538)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at dalvik.system.NativeStart.main(Native Method)
05-27 14:36:50.697: E/AndroidRuntime(31484): Caused by: java.lang.NullPointerException
05-27 14:36:50.697: E/AndroidRuntime(31484):    at com.webmonopolists.project_linx.RouteSummary.onCreate(RouteSummary.java:42)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
05-27 14:36:50.697: E/AndroidRuntime(31484):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1698)
05-27 14:36:50.697: E/AndroidRuntime(31484):    ... 11 more

Does startService always create a new Service or is the Intent sent to the existing one?

I am developing an Android application where I start a Service via an Intent. The service opens a connection and reports its success to an Activity. Afterwars the user shall be able to start a data transmission via Button click. This is also done by the service.

Is it the best way to send another Intent to my service? And does a service always exist only once or is another instance created of it?

onPostExecute() does not send the intent to the onNewIntent() in the backgroud

I am facing problem with onPostExecute() in the background so I am sending data like long, lat, mac to the server every 30 seconds and a response is coming back with the result as:

{
    "status":230,
    "routes":[9, 11],
    "distance":293.3018920430205
}

which are being processed well when the App runs in the front (the data is being passed to the onNewIntent method) but when it runs in the background the data is not being passed to onNewIntent in the MainActivity at all. How can I get that to work to also send the route and the distance to the MainActivity when the app is running in the background?

public class PostData {
    String jSONString;


    // Context mContext;

    public PostData() {
        super();

    }

    public String getjSONString() {
        return jSONString;

    }

    public void setjSONString(String jSONString) {
        this.jSONString = jSONString;
    }

    public void post_data(String jSONString, Context context) {
        this.jSONString = jSONString;

        new MyAsyncTask(context).execute(jSONString);
        //new MyAsyncTask(context).cancel(true);


    }

    class MyAsyncTask extends AsyncTask<String, Integer, Void> {
        final Context mContext;
        ArrayList<Integer> routes = new ArrayList<Integer>();
        double distance;

        public MyAsyncTask(Context context) {
            mContext = context;
        }

        @Override
        protected Void doInBackground(String... params) {
            // TODO Auto-generated method stub
            BufferedReader reader = null;

            try {
                System.out.println("The output of : doInBackground "
                        + params[0]);

                URL myUrl = new URL(
                        "http://ift.tt/1Ew06A3");
                HttpURLConnection conn = (HttpURLConnection) myUrl
                        .openConnection();
                conn.setRequestMethod("POST");
                conn.setDoOutput(true);
                conn.setConnectTimeout(10000);
                conn.setReadTimeout(10000);
                conn.setRequestProperty("Content-Type", "application/json");
                conn.connect();

                // System.out.println("The output of getResponsecode: "
                // + conn.getResponseCode());
                // create data output stream
                DataOutputStream wr = new DataOutputStream(
                        conn.getOutputStream());
                wr.writeBytes(params[0]);

                wr.close();

                StringBuilder sb = new StringBuilder();
                reader = new BufferedReader(new InputStreamReader(
                        conn.getInputStream()));
                String line;

                while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");

                }

                Gson gson = new Gson();
                StopsJSON data = gson.fromJson(sb.toString(), StopsJSON.class);

                routes = data.getRoutes();
                distance = data.getDistance();

                System.out.println("The output of the StringBulder: "
                        + sb.toString());

            } catch (IOException e) {

                e.printStackTrace();
                return null;
            } finally {
                if (reader != null) {
                    try {
                        reader.close();
                        return null;
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }

            return null;

        }

        @Override
        protected void onPostExecute(Void result) {

            // Intent with Conetxt of the Asyntask class and
            if (routes != null && !routes.isEmpty())  {
                // if(routes !=null ){
                Intent intent = new Intent(mContext, MainActivity.class);
                intent.putIntegerArrayListExtra("stop_route", routes);
                 intent.putExtra("stop_distance", distance);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                mContext.startActivity(intent);

            } else {
                Log.e("123", "Avoiding null pointer, the routes are null!!!");

            }

        }

    }

}

How do anti-virus software programmatically scan code of installed android apps (without root privileges)?

There are several android anti-virus softwares which I know of e.g:

  • AVG Mobile
  • AVAST Software
  • McAfee (Intel Security)
  • Norton Mobile
  • Kaspersky Lаb

etc.

Each of which offer functionality to scan installed android applications for viruses etc. (even android devices which aren't rooted).

Screenshots proving the above are below:

http://ift.tt/1emDTPL

http://ift.tt/1F2CJP7

http://ift.tt/1emDRY9

But from what I know of apps installed on unrooted Android devices, one app can't access another installed app and its associated files e.g:

  • Pre-Install (i.e. Camera, Calendar, Browser,etc.) APK stored in /system/app/

  • User Install (ApiDemo, Any.do, etc.) APK stored in /data/app/

  • Package Manager create data directory /data/data// to store database, shared preference, native library and cache data

So how do applications like those described above, programmatically scan applications and their associated files as described above (Without root access)

mardi 26 mai 2015

Launch default SMS app without a message

I am wanting my app to, on a button click, launch the user's default texting app. The intention is not to have the user send a message, but to view their current text conversations, therefore I don't want it to launch the SMS app's "New Message" activity but instead the main app's activity itself.

If I do the following:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:"));
context.startActivity(sendIntent);

Then this is launched, instead I want it to launch the main part of the app, not this new message screen:

enter image description here

How to get Audio source for FM audio stream recording?

I am trying to record FM radio audio stream. I am able to record with one audio source which is 9 for Motorola.

But when i tried with different phones it not working. So i wondering how to get this audio source dynamically.

This is how i am recording

 //RX_SRC is the FM receiving Antenna
   mRecorder = new AudioRecord(10, sampleRateInHz,
                            channelConfigIn,
                            AudioFormat.ENCODING_PCM_16BIT,
                            bufferSizeInBytes);                 

Please help me.

How to send e-mail intent to app Inbox

I'm trying to send an e-mail intent from my app to default e-mail app, simple. When I send to Gmail, works fine, but when the choosed app was the new "Inbox", doesn't works. How can I send e-mail intent, but one that works both e-mail apps?

onPostExecute() does not send the intent to the onNewIntent() in the backgroud

I am facing problem with onPostExecute() in the background so I am sending data like long, lat, mac to the server every 30 seconds and a response is coming back with the result like

{
    "status":230,
    "routes":[9],
    "distance":293.3018920430205
}

which are being processed well when the App runs in the front but when it runs in the background the data is not being sent to onNewIntent in the MainActivity at all. How can I get that to work to also send the route and the distance to the MainActivity when the app is running in the background?

public class PostData {
    String jSONString;


    // Context mContext;

    public PostData() {
        super();

    }

    public String getjSONString() {
        return jSONString;

    }

    public void setjSONString(String jSONString) {
        this.jSONString = jSONString;
    }

    public void post_data(String jSONString, Context context) {
        this.jSONString = jSONString;

        new MyAsyncTask(context).execute(jSONString);
        //new MyAsyncTask(context).cancel(true);


    }

    class MyAsyncTask extends AsyncTask<String, Integer, Void> {
        final Context mContext;
        ArrayList<Integer> routes = new ArrayList<Integer>();
        double distance;

        public MyAsyncTask(Context context) {
            mContext = context;
        }

        @Override
        protected Void doInBackground(String... params) {
            // TODO Auto-generated method stub
            BufferedReader reader = null;

            try {
                System.out.println("The output of : doInBackground "
                        + params[0]);

                URL myUrl = new URL(
                        "http://ift.tt/1Ew06A3");
                HttpURLConnection conn = (HttpURLConnection) myUrl
                        .openConnection();
                conn.setRequestMethod("POST");
                conn.setDoOutput(true);
                conn.setConnectTimeout(10000);
                conn.setReadTimeout(10000);
                conn.setRequestProperty("Content-Type", "application/json");
                conn.connect();

                // System.out.println("The output of getResponsecode: "
                // + conn.getResponseCode());
                // create data output stream
                DataOutputStream wr = new DataOutputStream(
                        conn.getOutputStream());
                wr.writeBytes(params[0]);

                wr.close();

                StringBuilder sb = new StringBuilder();
                reader = new BufferedReader(new InputStreamReader(
                        conn.getInputStream()));
                String line;

                while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");

                }

                Gson gson = new Gson();
                StopsJSON data = gson.fromJson(sb.toString(), StopsJSON.class);

                routes = data.getRoutes();
                distance = data.getDistance();

                System.out.println("The output of the StringBulder: "
                        + sb.toString());

            } catch (IOException e) {

                e.printStackTrace();
                return null;
            } finally {
                if (reader != null) {
                    try {
                        reader.close();
                        return null;
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }

            return null;

        }

        @Override
        protected void onPostExecute(Void result) {

            // Intent with Conetxt of the Asyntask class and
            if (routes != null && !routes.isEmpty())  {
                // if(routes !=null ){
                Intent intent = new Intent(mContext, MainActivity.class);
                intent.putIntegerArrayListExtra("stop_route", routes);
                 intent.putExtra("stop_distance", distance);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                mContext.startActivity(intent);

            } else {
                Log.e("123", "Avoiding null pointer, the routes are null!!!");

            }

        }

    }

}

"java.lang.RuntimeException: Could not launch intent" for UI with indeterminate ProgressBar

Are there any known issues with displaying indeterminate ProgressBars with the AndroidJUnitRunner?  I'm hitting this error during tests:

05-26 15:22:48.504    1003-1016/? I/TestRunner﹕ java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=http://ift.tt/1Ew06Ql } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1432668122421 and now the last time the queue went idle was: 1432668122421. If these numbers are the same your activity might be hogging the event queue.

The stack trace is:

05-26 15:22:48.504    1003-1016/? I/TestRunner﹕ java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=http://ift.tt/1Ew06Ql } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1432668122421 and now the last time the queue went idle was: 1432668122421. If these numbers are the same your activity might be hogging the event queue.
            at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:274)
            at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:119)
            at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:97)
            at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:104)
            at com.cookbrite.step2_functional.ui.homelist.HomeListFragmentLoadingTest.testLoadingSpinner(HomeListFragmentLoadingTest.java:40)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
            at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
            at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
            at com.cookbrite.util.BaseBlackBoxTest.doRunTest(BaseBlackBoxTest.java:300)
            at com.cookbrite.util.BaseBlackBoxTest.access$000(BaseBlackBoxTest.java:44)
            at com.cookbrite.util.BaseBlackBoxTest$1.call(BaseBlackBoxTest.java:271)
            at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:841)

The thread dump triggered by the above timeout shows the ProgressBar appears to be involved:

05-26 15:22:48.135    1003-1018/? E/THREAD_STATE﹕ Thread[main,5,main]
    android.graphics.Canvas.native_drawBitmap(Native Method)
    android.graphics.Canvas.drawBitmap(Canvas.java:1160)
    android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:440)
    android.graphics.drawable.RotateDrawable.draw(RotateDrawable.java:88)
    android.graphics.drawable.LayerDrawable.draw(LayerDrawable.java:345)
    android.widget.ProgressBar.onDraw(ProgressBar.java:1052)
    android.view.View.draw(View.java:13944)
    android.view.View.draw(View.java:13825)
    android.view.ViewGroup.drawChild(ViewGroup.java:3086)
    android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
    android.view.View.draw(View.java:13823)
    android.view.ViewGroup.drawChild(ViewGroup.java:3086)
    android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
    android.view.View.draw(View.java:13947)
    android.view.View.draw(View.java:13825)
    android.view.ViewGroup.drawChild(ViewGroup.java:3086)
    android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
    android.view.View.draw(View.java:13823)
    android.view.ViewGroup.drawChild(ViewGroup.java:3086)
    android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
    android.view.View.draw(View.java:13947)
    android.widget.FrameLayout.draw(FrameLayout.java:467)
    android.view.View.draw(View.java:13825)
    android.view.ViewGroup.drawChild(ViewGroup.java:3086)
    android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
    android.view.View.draw(View.java:13823)
    android.view.ViewGroup.drawChild(ViewGroup.java:3086)
    android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
    android.view.View.draw(View.java:13947)
    android.widget.FrameLayout.draw(FrameLayout.java:467)
    com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2224)
    android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2482)
    android.view.ViewRootImpl.draw(ViewRootImpl.java:2395)
    android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2239)
    android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1872)
    android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
    android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
    android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
    android.view.Choreographer.doCallbacks(Choreographer.java:562)
    android.view.Choreographer.doFrame(Choreographer.java:532)
    android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
    android.os.Handler.handleCallback(Handler.java:730)
    android.os.Handler.dispatchMessage(Handler.java:92)
    android.os.Looper.loop(Looper.java:137)
    android.app.ActivityThread.main(ActivityThread.java:5103)
    java.lang.reflect.Method.invokeNative(Native Method)
    java.lang.reflect.Method.invoke(Method.java:525)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    dalvik.system.NativeStart.main(Native Method)
    Thread[Binder_2,5,main]
    dalvik.system.NativeStart.run(Native Method)
    Thread[JDWP,5,system]
    dalvik.system.NativeStart.run(Native Method)
    Thread[pool-1-thread-1,5,main]
    java.lang.Object.wait(Native Method)
    java.lang.Object.wait(Object.java:364)
    android.app.Instrumentation.startActivitySync(Instrumentation.java:403)
    android.support.test.runner.MonitoringInstrumentation.access$101(MonitoringInstrumentation.java:69)
    android.support.test.runner.MonitoringInstrumentation$3.call(MonitoringInstrumentation.java:265)
    android.support.test.runner.MonitoringInstrumentation$3.call(MonitoringInstrumentation.java:262)
    java.util.concurrent.FutureTask.run(FutureTask.java:234)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    java.lang.Thread.run(Thread.java:841)
    Thread[pool-5-thread-1,5,main]
    dalvik.system.VMStack.getThreadStackTrace(Native Method)
    java.lang.Thread.getStackTrace

When using Intent.putExtra() and Intent.getStringExtra(), are we working with the Bundle?

Simple and silly question, but I couldn't confirm it yet.

From what I understood and tested, Intent.getStringExtra() is the same as Intent.getExtras().getString() (assuming we have data to fetch).

From the documentation, what Intent.getStringExtra() does:

Retrieve extended data from the intent.

Is Intent.getStringExtra() extracting this extended data from its Bundle?

Please provide a reference to your answer.

Using Intent to call class

!I want to call the MainLayoutActivity from the selection class but it is not working. i had already added MainLayoutActivity to manifest but still not working

Passing extras from Activity to Intent throws NullPointerException

This is a problem that forked off a different issue.

I'm passing two strings from my main activity to a child service, which is fine, but when the main activity dies, the service throws a NullPointerException trying to grab the two strings.

From MainActivity:

Intent i = new Intent(this, PebbleService.class);
i.putExtra("quote", quote[0]);
i.putExtra("author", quote[1]);
startService(i);

From PebbleService:

public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);

    final String author = intent.getStringExtra("author");
    final String quote = intent.getStringExtra("quote");

    // Define AppMessage behavior
    if (appMessageReciever == null) {
        appMessageReciever = new PebbleKit.PebbleDataReceiver(WATCHAPP_UUID) {

            @Override
            public void receiveData(Context context, int transactionId, PebbleDictionary data) {
                // Always ACK
                PebbleKit.sendAckToPebble(context, transactionId);

                // Send KEY_QUOTE to Pebble
                PebbleDictionary out = new PebbleDictionary();
                out.addString(KEY_QUOTE, quote);
                out.addString(KEY_AUTHOR, author);
                PebbleKit.sendDataToPebble(getApplicationContext(), WATCHAPP_UUID, out);
            }
        };

        // Add AppMessage capabilities
        PebbleKit.registerReceivedDataHandler(this, appMessageReciever);
    }

    return START_STICKY;
}

Error from Logcat:

05-26 10:29:52.972    4147-4147/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: net.thevgc.quotes, PID: 4147
    java.lang.RuntimeException: Unable to start service net.thevgc.quotes.PebbleService@423eb138 with null: java.lang.NullPointerException
            at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2732)
            at android.app.ActivityThread.access$2100(ActivityThread.java:139)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5086)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at net.thevgc.quotes.PebbleService.onStartCommand(PebbleService.java:34)
            at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2715)
            at android.app.ActivityThread.access$2100(ActivityThread.java:139)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5086)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

can't get image from send intent in lollipop

I have been googling and fiddling for hours, just to find out that the problem was not (only) my code but mainly lollipop! I want to create a new sharing app that receives data from other apps using ACTION_SEND. This tutorial is great, but does not work on my nexus 9 with lollipop 5.1.1. Apparently the sharing of images works just fine with other apps like evernote so clearly there is a right way of doing things. Could anyone oblige to point me in the right direction?

Android make phone call by clicking a button not working for Galaxy 5

In my Android application I have to make phone call to a particular number by clicking a button. I had written the following for that, it is working fine in my phone.

The same code is not working for client's mobile, he is having Galaxy 5, is there any reason for this

public void onClick(View v) {
  String number = "123456789";
  Intent intent = new Intent(Intent.ACTION_CALL);
  intent.setData(Uri.parse("tel:" + number));
  startActivity(intent);
}

I had used this also in the manifest

<uses-permission android:name="android.permission.CALL_PHONE" />

Can anyone help me.

How turn on GPS programmatically in my android application?

If we use this code we see a message: searching for GPS. However, the GPS symbol is merely shown; GPS doesn't actually work:

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

    Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
    intent.putExtra("enabled", true);
    this.sendBroadcast(intent);   
}

Why isn't it working ? And how to make it work correctly ?

How to peek at Intent Extras in Android

I have an application that starts Activity with extras. I would like to see what extras are inside Intent. Both applications (calling and called) are not written by me.

Location Based activity, opening intent according to the distance

I am developing an app who makes basically the following things: when the GPS is enabled it takes the current position and calculates the distance between the location took from the location manager and a fixed position, then when the distance is lower than a value, for example 10 meters, the app automatically open another Activity containing the informations about the location reached, the problem is that when the user is visualizing the info page he remains in the range and the previous activity continues opening the same activity with informations, how can i prevent this problem? I need to stop the method that open the new Intent when the info are visualized and then restart when the user is back in the distance calculation Activity.

ListView item button action

**i am trying to press the button in list item then the calories of this item will be added on a circular progress bar and the table will be disabled but the progress increase only when i press one button then stop also another button is disabled not the pressed button .

public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.meal_layout, parent,false);
        meal = MealList.get(position);
        TextView cal = (TextView)view.findViewById(R.id.calories);
        TextView desc= (TextView) view.findViewById(R.id.desc);
        TextView title = (TextView) view.findViewById(R.id.title);
        add = (Button) view.findViewById(R.id.button1);
        cal.setText("سعرة"+meal.getCalories());
        desc.setText(meal.getDescription());
        title.setText(meal.getTitle());

    add.setOnClickListener(new OnClickListener() {






            @Override
            public void onClick(View v) {
                calories = Integer.parseInt(meal.getCalories());
                add.setEnabled(false);




            }
        });

        return view;


}*

then the progress activity

  public class ProgressActivity extends Activity{
    ProgressBar pb;
    int percent;
    Double BMR;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result_layout);
        pb = (ProgressBar) findViewById(R.id.progressBarToday);
    /*Bundle extras = getIntent().getExtras();
        if (extras != null) {
           BMR = extras.getDouble("BMR");}*/
        percent = (int) ((Cadapter.calories/10));
        pb.setProgress(pb.getProgress()+percent);

    }

}*

how to use intents in recyclerview items of navigation drawer to open a new activity fragment?

My activity class is like following:

    /*ToolBar SetUp*/
    app_toolBar = (Toolbar) findViewById(R.id.toolbar_header);
    setSupportActionBar(app_toolBar);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);


    String TITLES[] = {"Home", "Search", "HalalRewards", "Contact Us", "User Guide", "F.A.Q", "Settings", "Share"};
    int ICONS[] = {R.drawable.ic_action_home, R.drawable.ic_search, R.drawable.ic_rewardsss, R.drawable.ic_contact, R.drawable.ic_uguide, R.drawable.ic_faq, R.drawable.ic_settings, R.drawable.ic_shareee};

    String NAME = "ESignature IT Solution";
    String EMAIL = "info@esignature.com.np";
    int PROFILE = R.drawable.intologo;

    /*Drawer SetUp*/
    mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView); // Assigning the RecyclerView Object to the xml View
    mRecyclerView.setHasFixedSize(true);                            // Letting the system know that the list objects are of fixed size


    mAdapter = new DrawerAdapter(TITLES, ICONS, NAME, EMAIL, PROFILE);
    // Creating the Adapter of MyAdapter class(which we are going to see in a bit)
    // And passing the titles,icons,header view name, header view email,
    // and header view profile picture

    mRecyclerView.setAdapter(mAdapter);                              // Setting the adapter to RecyclerView
    mRecyclerView.setOnClickListener(new DrawerItemClickListener());
    mLayoutManager = new LinearLayoutManager(this);                 // Creating a layout Manager

    mRecyclerView.setLayoutManager(mLayoutManager);                 // Setting the layout Manager


    Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout);        // Drawer object Assigned to the view
    mDrawerToggle = new ActionBarDrawerToggle(this, Drawer, app_toolBar, R.string.openDrawer, R.string.closeDrawer) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // TO DO Execute code when Drawer view open
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            // TO DO Execute code when once Drawer is close
        }


    };
    Drawer.setDrawerListener(mDrawerToggle); // Drawer Listener set to the Drawer toggle
    mDrawerToggle.syncState();               // Finally we set the drawer toggle sync State

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

        case R.id.action_settings:
            return true;

    }

    return super.onOptionsItemSelected(item);
}

// create fragmrnt loader funtion
// id get from adapter ....


/* The click listner for ListView in the navigation drawer */
private class DrawerItemClickListener implements AdapterView.OnItemClickListener, View.OnClickListener {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        /*selectItem(position);*/ ///////////
        // display view for selected nav drawer item
        displayView(position);

    }


    @Override
    public void onClick(View v) {

    }
}

// Diplaying fragment view for selected nav drawer list item
private void displayView(int position) {
    // update the main content by replacing fragments
    Fragment fragment = null;
    switch (position) {
        /*case 0:
            fragment = new Fragment();
            break;*/
        case 1:
            fragment = new SearchActivity();
            break;
         case 2:
            fragment = new HalalRewardsActivity();
            break;
        case 3:
            fragment = new ContactUsFragment();
            break;
        case 4:
            fragment = new GuideFragment();
            break;
        case 5:
            fragment = new FaqFragment();
            break;
        case 6:
            fragment = new SettingsFragment();
            break;
        case 7:
            fragment = new ShareFragment();
            break;

        default:
            break;
    }

    if (fragment != null) {
        FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.content_frame, fragment).commit();


        Drawer.closeDrawer(mRecyclerView);
    } else {
        // error in creating fragment
        Log.e("MainActivity", "Error in creating fragment");
    }
}
}

I am a new programmer. So proper help would be praiseworthy. Thanks in advance.

How can I open android application activity from email?

We are sending user email as notification. Email body has Accept and Reject button.We are sending emails from android application as well as from web application to user. want to open an our application if user clicks on button contained in email. If user checks an email from android device and clicks on button, respective activity should be opened for user convenience. How can I open that activity if application is installed.

Thanks,

Prashant.

android intent: when can the action be null?

In an already existing projects I see that a service checks if the intent is null and if the intent action is null.

I know that the intent action will be null if the service is invoked as:

context.startService(new Intent(context, MyService.class));

but I do not know whether or not the framework does such invocations.

Does the system ever start a service with a null intent action?

Is it possible that a service is started with null intent?

Image share (post) on facebook from resourse drawable folder

I am making an application for which I need to share an image with text on facebook timeline. However with my code i can share a link to the facebook wall but cannot share Image. I already tried most of the code of stack overflow. but not succeed yet. Here is my code.

MainActivity.java

 package com.example.test2;



import com.facebook.android.Facebook;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;

public class MainActivity extends Activity {

String[] ShareOption;
Spinner ShareOptionList;
int driverStarScore = 1; //2 or 3 ...
Facebook facebookClient;    
SharedPreferences mPrefs;

ListView list;

 String[] ShareItemName ={

 "Dropbox",
 "Email",
 "Facebook",
 "Google Plus",
 "Twitter",
 "Whatsapp",

 };

 Integer[] ShareImageId={

         R.drawable.ic_dropbox,
         R.drawable.ic_email,
         R.drawable.ic_facebook,
         R.drawable.ic_googleplus,
         R.drawable.ic_twitter,
         R.drawable.ic_whatsapp,

         };
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);






    ShareOptionList=(Spinner) findViewById(R.id.spinner_ShareScore);
    ShareOption=getResources().getStringArray(R.array.ShareChooseOption);
    ArrayAdapter<String> adapter1=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,ShareOption);
    ShareOptionList.setAdapter(adapter1);

    ShareOptionList.setOnItemSelectedListener(new OnItemSelectedListener(){

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            // TODO Auto-generated method stub
            int index=arg0.getSelectedItemPosition();
            Toast.makeText(getBaseContext(), "You select "+ ShareOption[index],Toast.LENGTH_LONG).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }



    });




    ShareListAdapter adapter=new ShareListAdapter(this, ShareItemName, ShareImageId);
    list=(ListView)findViewById(R.id.listview_share);
    list.setAdapter(adapter);

    list.setOnItemClickListener(new OnItemClickListener() {

        @Override
         public void onItemClick(AdapterView<?> parent, View view,
         int position, long id) {
         // TODO Auto-generated method stub
         String Selecteditem= ShareItemName[+position];

         Toast.makeText(MainActivity.this, Selecteditem, Toast.LENGTH_SHORT).show();

         if(Selecteditem=="Facebook"){  


            // if (driverStarScore == 1){
                 //Uri pngUri = Uri.parse("file//res/drawable/star_1.png");
            // }
             //if (driverStarScore == 2){
                // Uri pngUri = Uri.parse("file//res/drawable/star_2.png");
        // }

            String urlToShare = "http://ift.tt/1HjlpH0";

             try {

                    Intent facebook1 = new Intent();
                    facebook1.setClassName("com.facebook.katana", "com.facebook.katana.activity.composer.ImplicitShareIntentHandler");
                    facebook1.setAction("android.intent.action.SEND");
                    facebook1.setType("image/png");
                    facebook1.putExtra("android.intent.extra.TEXT", urlToShare);
                    startActivity(facebook1);

             } catch (Exception e) {
                    // If we failed (not native FB app installed), try share through SEND
                    Intent facebook = new Intent(Intent.ACTION_SEND);
                    String sharerUrl = "http://ift.tt/Z4FwYQ" + urlToShare;
                    facebook = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
                    startActivity(facebook);
                }


         }
         if(Selecteditem=="Email"){
            Intent email = new Intent(Intent.ACTION_SEND);

            email.setType("message/rfc822");
            email.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"}); // if you want to add email address also.
            email.putExtra(android.content.Intent.EXTRA_TEXT, "Sample Text");
            email.putExtra(Intent.EXTRA_SUBJECT, "Driving Score Email");

            try {
                startActivity(Intent.createChooser(email, "Send mail..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            }
         }

        }
         });



}

/** * */

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }





@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.


    return super.onOptionsItemSelected(item);
}

}

AndroidManifest.xml

        <?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="http://ift.tt/nIICcg"
            package="com.example.test2"
            android:versionCode="1"
            android:versionName="1.0" >

            <uses-sdk
                android:minSdkVersion="16"
                android:targetSdkVersion="18" />

            <application
                android:allowBackup="true"
                android:icon="@drawable/ic_launcher"
                android:label="@string/app_name"
                android:theme="@style/AppTheme" >
                <activity
                    android:name=".MainActivity"
                    android:label="@string/app_name" >
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN" />

                        <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
                </activity>
                <activity
                    android:name=".Menu"
                    android:label="@string/app_name" >
                    <intent-filter>
                        <action android:name="android.intent.action.Menu" />
                        <data android:mimeType="image/png" />
                        <category android:name="android.intent.category.DEFAULT" />
                    </intent-filter>
                </activity>

              <activity
                        android:name="com.sample.socialshare.facebookUpload"
                        android:label="@string/app_name"
                        android:theme="@android:style/Theme.DeviceDefault.Dialog">
                        <intent-filter>
                            <action android:name="android.intent.action.VIEW" />
                            <category android:name="android.intent.category.DEFAULT" />
                        </intent-filter>
                </activity>


                        </application>
                <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>


        </manifest>