Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23953] Hyperloop: Android - Fails to cast Ti.Android.Intent to native Android Intent

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-09-29T07:03:32.000+0000
Affected Version/shyperloop 1.2.7
Fix Version/sRelease 6.0.0, Hyperloop 2.0.0, hyperloop 1.2.8
ComponentsHyperloop
LabelsAndroid, Hyperloop
ReporterBrian Knorr
AssigneeChristopher Williams
Created2016-09-27T16:22:54.000+0000
Updated2016-10-25T22:55:41.000+0000

Description

We need the ability to cast a Ti Intent to a native Android Intent so we can use the method getParcelableExtra. Unfortunately Hyperloop throws an error when casting. Here is the simple way to reproduce:
var Intent = require('android.content.Intent');
var intent = Ti.Android.createIntent();
var nativeIntent = new Intent(intent); // Fails
{quote} [ERROR] : HyperloopProxy: (main) [209,209] Unable to find matching constructor for class: android.content.Intent, args: [org.appcelerator.titanium.proxy.IntentProxy@1a8a7c43] {quote}

Comments

  1. Christopher Williams 2016-09-28

    master: https://github.com/appcelerator/hyperloop.next/pull/78 1_2_X: https://github.com/appcelerator/hyperloop.next/pull/80
  2. Hans Knöchel 2016-09-28

    Test-case:
       var Intent = require('android.content.Intent');
       var Activity = require('android.app.Activity');
       var Uri = require("android.net.Uri");
       
       var win = Ti.UI.createWindow({
           backgroundColor: "#fff"
       });
       
       var btn = Ti.UI.createButton({
           title: "Trigger"
       });
       
       btn.addEventListener("click", openIntent);
       
       win.add(btn);
       win.open();
       
       function openIntent() {
           var activity = new Activity(Ti.Android.currentActivity);
           
           var intent = Ti.Android.createIntent({
               action: Ti.Android.ACTION_VIEW
           });
           
           var nativeIntent = new Intent(intent);
           nativeIntent.setData(Uri.parse("sms://"));
           nativeIntent.putExtra("sms_body", "Hello world!"); 
           
           activity.startActivity(nativeIntent);
       }
       
  3. Lokesh Choudhary 2016-10-25

    Verified the fix. Closing. Appc Studio : 4.8.0.201610171310 SDK Version : 6.0.0.v20161025114857 Mac OS Version : 10.11.6 Xcode Version : Xcode 8.0 Build version 8A218a Appc CLI AND Appc NPM : {"NPM":"4.2.8-9","CLI":"6.0.0-65"} Ti CLI : 5.0.10 Alloy : 1.9.3 Node : v4.6.0 Environment: preprod Nexus 6 : android 6.0.1

JSON Source