1

There seems to be a working example here in Java (I guess). For clarity I will paste the code:

try {
            PackageManager packageManager = context.getPackageManager();
            Intent i = new Intent(Intent.ACTION_VIEW);
            String url = "https://api.whatsapp.com/send?phone="+ phone +"&text=" + URLEncoder.encode(message, "UTF-8");
            i.setPackage("com.whatsapp");
            i.setData(Uri.parse(url));
            if (i.resolveActivity(packageManager) != null) {
                context.startActivity(i);
            }
        } catch (Exception e){
            e.printStackTrace();
        }

Now I've been trying to achive the same using QPython and Androidhelper (I guess this is just SL4A) and my attempt looks like this:

import androidhelper
droid = androidhelper.Android()

activity = 'android.intent.action.ACTION_VIEW'

packagename =  'com.whatsapp'
uri='http://api.whatsapp.com/send?phone=*********&text=TEST'
uritype='UTF-8'

intent = droid.makeIntent(activity, uri, None,None,None, packagename, None,None).result
droid.startActivityIntent(intent,None)

I'm not sure what 'uritype' should be set to. Further, I've no clue, whether 'Intent.ACTION_VIEW' is correct. I've tried several variations such as 'android.intent.action.ACTION_VIEW'. 'android.intent.ACTION_VIEW', 'Android.Intent.ACTION_VIEW' etc.

I guess the most critical part however is the 'classname'-Attribute (2nd to last one) The (poorly documented) SL4A API help says that this attribute needs to be specified in case 'packagename' is specified.

Any ideas?

The script runs without giving any warnings or errors. Since I'm a 'C'-person I'm very confused because I've no idea where to start searching for my mistake.

OD IUM
  • 1,555
  • 2
  • 16
  • 26

0 Answers0