Project: titanium
Issue TIMOB-19490: Android: Error when accessing Actionbar
Regression in Master branch using this code: https://jira.appcelerator.org/browse/TIMOB-16619 Actionbar is not available as the activities are no longer extending ActionBarActivity. Instead, they are AppCompatActivity. {code} var win = Ti.UI.createWindow({ title: "Old Title", navBarHidden: false }); var actionBar; win.addEventListener("open", function() { if (Ti.Platform.osname === "android") { if (! win.activity) { Ti.API.error("Can't access action bar on a lightweight window."); } else { actionBar = win.activity.actionBar; if (actionBar) { actionBar.backgroundImage = "/bg.png"; actionBar.title = "New Title"; actionBar.onHomeIconItemSelected = function() { Ti.API.info("Home icon clicked!"); }; } } } }); win.open(); {code} {code} [WARN] : W/System.err: java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity [WARN] : W/System.err: org.appcelerator.titanium.proxy.ActivityProxy.getActionBar(ActivityProxy.java:255) [WARN] : W/System.err: org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [WARN] : W/System.err: org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) [WARN] : W/System.err: org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:908) [WARN] : W/System.err: org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1131) [WARN] : W/System.err: org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:349) [WARN] : W/System.err: org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:102) [WARN] : W/System.err: ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:428) [WARN] : W/System.err: android.os.Handler.dispatchMessage(Handler.java:98) [WARN] : W/System.err: android.os.Looper.loop(Looper.java:136) [WARN] : W/System.err: org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) [ERROR] : TiExceptionHandler: (main) [286,286] ----- Titanium Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main) [0,286] - In app.js:12,37 [ERROR] : TiExceptionHandler: (main) [1,287] - Message: Uncaught Error: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity [ERROR] : TiExceptionHandler: (main) [1,288] - Source: actionBar = win.activity.actionBar; [ERROR] : V8Exception: Exception occurred at app.js:12: Uncaught Error: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity {code}
Story points: 3