[AC-5950] Hyperloop: Android PhoneStateListener apiName returns null
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Needs more info |
Resolution Date | 2018-12-03T21:30:56.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop |
Labels | android, hyperloop |
Reporter | Michael Gangolf |
Assignee | Shak Hossain |
Created | 2018-10-01T16:05:45.000+0000 |
Updated | 2018-12-03T21:40:42.000+0000 |
Description
When trying to add PhoneStateListener to get the cell information most listeners work besides
onCellInfoChanged
. When I add this I'll end up with:
_Cannot read property 'apiName' of null_
{noformat}
[ERROR] TiExceptionHandler: (main) [51,51] /hyperloop/android.telephony.PhoneStateListener.js:1
[ERROR] TiExceptionHandler: (function (exports, require, module, __filename, __dirname, Titanium, Ti, global, kroll) {var Hyperloop=require('hyperloop'),parentPackage=require('./android.telephony'),PhoneStateListener=function(){var a;a=1==arguments.length&&arguments[0].isNativeProxy&&arguments[0].isInstanceProxy&&arguments[0].isInstanceOf('android.telephony.PhoneStateListener')?arguments[0]:PhoneStateListener.class.newInstance(arguments),this.$native=a,this._hasPointer=null!=a,this._private={}},SuperClass=require('./java.lang.Object');PhoneStateListener.prototype=Object.create(SuperClass.prototype),PhoneStateListener.prototype.constructor=PhoneStateListener,Object.defineProperty(PhoneStateListener.prototype,'super',{get:function(){return this._hasPointer?new PhoneStateListener(this.$native.super):null},enumerable:!0}),PhoneStateListener.className='android.telephony.PhoneStateListener',PhoneStateListener.prototype.className='android.telephony.PhoneStateListener',Object.defineProperty(PhoneStateListener,'class',{get:function(){return Hyperloop.getClass('android.telephony.PhoneStateListener')},enumerable:!0,configurable:!1}),PhoneStateListener.extend=function(a){var b=Hyperloop.extend('android.telephony.PhoneStateListener'),c=function(){function c(a){if(a.apiName&&a.isNativeProxy&&a.isInstanceProxy){var b=require('./'+a.apiName);return new b(a)}return a}function d(){for(var a=[],b=0;bvar win = Ti.UI.createWindow({backgroundColor:"#fff"}); var GsmCellLocation = require("android.telephony.gsm.GsmCellLocation"); var TelephonyManager = require("android.telephony.TelephonyManager"); var CellInfoLte = require("android.telephony.CellInfoLte"); var CellInfoGsm = require("android.telephony.CellInfoGsm"); var Activity = require('android.app.Activity'); var activity = new Activity(Ti.Android.currentActivity); var Context = require("android.content.Context"); var tm = new TelephonyManager(activity) var PhoneStateListener = require("android.telephony.PhoneStateListener"); var psl = PhoneStateListener.extend({ onCellInfoChanged: function(ev) { console.log("onCellInfoChanged"); }, onCellLocationChanged: function(ev) { console.log("onCellLocationChanged " + ev); }, onServiceStateChanged: function(ev) { console.log("onServiceStateChanged " + ev); }, onSignalStrengthsChanged: function(ev) { console.log("onSignalStrengthsChanged " + ev); } }); tm.listen(new psl(), PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_CELL_INFO | PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_DATA_ACTIVITY | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR); win.open();Add this to tiapp.xml and enable the permissions manually:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
</manifest>
</android>
Hyperloop 3.1.3
Titanium SDK 7.4.0.GA
Android 7
Hello, Thanks for reporting this. Can you please test this on 7.5.0.GA again and let us know how it goes. It would be helpful if you can share your complete console log and environment details here.
Sorry for the late reply. Yes, with 7.5.0.GA it is the same error message. This is the complete error message:
Hyperloop 3.1.4 SDK 7.5.0.GA Android 7 (HTC A9)