Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15487] Android: Being able to name the activity related to a heavyweight window

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2014-04-03T19:15:39.000+0000
Affected Version/sRelease 3.1.3
Fix Version/s2014 Sprint 07, 2014 Sprint 07 SDK
ComponentsAndroid
LabelsSupportTeam
ReporterMauro Parra-Miranda
AssigneeVishal Duggal
Created2013-10-15T02:04:38.000+0000
Updated2017-03-22T22:53:44.000+0000

Description

Problem Description

Customer requieres to be able to set the activity name related to a heavyweight window, so he can refer to it from an external android native module.

Comments

  1. Ingo Muschenetz 2014-03-31

    We think that TiJSActivity is the correct short-term solution. We will revisit this as part of Ti.Next, as it requires breaking changes to the API.
  2. Vishal Duggal 2014-04-03

    The Current Titanium Windowing system is view centric. Although every heavyweight window creates a new Activity, the activity is one of two classes TiActivity and TiTranslucentActivity. There are two workarounds to this issue. 1. Create a native Android Activity and launch it through proper intents. The drawback of this method of course would be that you would not get a built in JS bridge. 2. Launch activities associated with java script files (Commonly referred to as JSActivity). The usage of the JSActivity is similar to the url parameter of the Ti.UI.Window class. Please note that the JSActivity thus created has no specific theme and will inherit the application theme. To determine the exact class name see the generated Android Manifest file in the build folder. To overwrite the default activity setting add corresponding entries to the tiapp.xml for the generated activity. The steps required to create and use a JS activity are as follows. 1. Add an entry to the tiapp.xml to declare the activity. In the android section of tiapp.xml add something similar to the entry below
       <activities>
           <activity url="myActivity.js"/>
       </activities>
       
    2. Create an intent to launch the activity associated with the JS file. Example below
       var intent = Ti.Android.createIntent({
           action: Ti.Android.ACTION_VIEW,
           url: 'myActivity.js'
       });
       
    3. Launch the intent with the top most activity Full code example shown below
       *************************
       File : app.js
       *************************
       var win = Ti.UI.createWindow({ title: 'JS ACTIVITIES',exitOnClose:true,backgroundColor:'white'});
        
       var b1 = Ti.UI.createButton({title:'START myActivity1'});
       
       b1.addEventListener('click',function(e) {
       	Ti.API.info('GOT CLICK. CREATING INTENT');
       	var intent = Ti.Android.createIntent({
       	    action: Ti.Android.ACTION_VIEW,
       	    url: 'myActivity.js'
       	});
       	Ti.API.info('STARTING ACTIVITY');
       	win.activity.startActivity(intent);
       });
       
       
       win.add(b1);
       
       win.open();
       *************************
       File : myActivity.js
       *************************
       var activity = Ti.Android.currentActivity;
       var win1 = Ti.UI.currentWindow;
       var button = Ti.UI.createButton({title:'Open Me Again'});
       win1.add(button);
       
       
       button.addEventListener('click',function(e) {
       	Ti.API.info('GOT CLICK. CREATING INTENT');
       	var intent = Ti.Android.createIntent({
       	    action: Ti.Android.ACTION_VIEW,
       	    url: 'myActivity.js'
       	});
       	Ti.API.info('STARTING ANOTHER INSTANCE OF MYSELF');
       	activity.startActivity(intent);
       });
       
       
       
       activity.addEventListener("create", function(e) {
       	Ti.API.info('IN CREATE OF myActivity');	
       });
       
       activity.addEventListener("destroy", function(e) {
       	Ti.API.info('IN DESTROY OF myActivity');	
       });
       
  3. Lee Morris 2017-03-22

    Closing ticket as "Won't Fix".

JSON Source