I download android sdk
where I copy android SDK for developed new extension?
any tutorial?
plz help me.
I download android sdk
where I copy android SDK for developed new extension?
any tutorial?
plz help me.
Hi Pradeep,
do you have experience programming in Java or C++ already?
In fact you don't need these SDK files. All what you need is in this template:
CRunTemplate.java
You can find examples in folder data/runtime/android all android extensions are open.Code:/* Copyright (c) 1996-2013 Clickteam * * This source code is part of the Android exporter for Clickteam Multimedia Fusion 2. * * Permission is hereby granted to any person obtaining a legal copy * of Clickteam Multimedia Fusion 2 to use or modify this source code for * debugging, optimizing, or customizing applications created with * Clickteam Multimedia Fusion 2. Any other use of this source code is prohibited. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package Extensions; import Actions.CActExtension; import Conditions.CCndExtension; import Expressions.CValue; import RunLoop.CCreateObjectInfo; import Services.CBinaryFile; public class CRunTemplate extends CRunExtension { public static final int CND_LAST = 0; @Override public int getNumberOfConditions() { return CND_LAST; } public boolean createRunObject(CBinaryFile file, CCreateObjectInfo cob, int version) { return true; } public void destroyRunObject(boolean bFast) { } public int handleRunObject() { return 0; } @Override public void continueRunObject() { } public boolean condition(int num, CCndExtension cnd) { /* switch (num) { case 0: return true; }*/ return false; } public void action(int num, CActExtension act) { /* switch (num) { case 0: break; }*/ } public CValue expression(int num) { /*switch (num) { case 0: return new CValue(0); }*/ return new CValue(0); } }![]()
What if you need to add lines to other files, such as adding activities to AndroidManifest.xml?
Then you need to do this in PrepareAndroidBuild function which is in the file edittime.cpp
example:
Code:// PrepareAndroidBuild void CALLBACK PrepareAndroidBuild(LPMV pMV, LPEDATA edPtr, LPCWSTR androidDirectoryPathname) { #if !defined(RUN_ONLY) // Load manifest file bool bModified = false; TCHAR manifestPathname[_MAX_PATH]; GetAndroidManifestPathname(manifestPathname, androidDirectoryPathname); LPSTR pAndroidManifestData = ReadTextFile(manifestPathname); if ( pAndroidManifestData != NULL ) { //////////////////////////////////////////////////////////////// // // Permissionss // //////////////////////////////////////////////////////////////// // Find string if ( strstr(pAndroidManifestData, "android.permission.WAKE_LOCK") == NULL ) { // <uses-permission android:name="android.permission.WAKE_LOCK"/> pAndroidManifestData = InsertString(pAndroidManifestData, "<application android:", " <uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\r\n"); bModified = true; } //////////////////////////////////////////////// // // receivers and services inside the application // //////////////////////////////////////////////// //if ( strstr(pAndroidManifestData, "com.cootje.extensions.MyAlarmService") == NULL ) // { // <service android:name="com.cootje.extensions.MyAlarmService" android:enabled="true" // pAndroidManifestData = InsertString(pAndroidManifestData, "</application", " <service android:name=\"com.cootje.extensions.MyAlarmService\"\r\n"); // pAndroidManifestData = InsertString(pAndroidManifestData, "</application", " android:enabled=\"true\"/>\r\n"); // bModified = true; // } char * stemp = new char[47]; strcpy(stemp,"<action android:name=\""); strcat(stemp,edPtr->szUniqueID); strcat(stemp,"\"/>\r\n"); if ( strstr(pAndroidManifestData, "com.cootje.extensions.MyAlarmReceiver") == NULL ) { pAndroidManifestData = InsertString(pAndroidManifestData, "</application", " <receiver android:name=\"com.cootje.extensions.MyAlarmReceiver\" >\r\n"); pAndroidManifestData = InsertString(pAndroidManifestData, "</application", " <intent-filter>\r\n"); pAndroidManifestData = InsertString(pAndroidManifestData, "</application", stemp); pAndroidManifestData = InsertString(pAndroidManifestData, "</application", " </intent-filter>\r\n"); pAndroidManifestData = InsertString(pAndroidManifestData, "</application", " </receiver>\r\n"); bModified = true; } delete [] stemp; if ( bModified ) WriteTextFile(manifestPathname, pAndroidManifestData); } #endif // !defined(RUN_ONLY) }
Awesome, thank you!
i am bit confused what is going on here:
TCHAR manifestPathname[_MAX_PATH];
GetAndroidManifestPathname(manifestPathname, androidDirectoryPathname);
LPSTR pAndroidManifestData = ReadTextFile(manifestPathname);
GetAndroidManifestPathname() must be some method defined elsewhere?
i am thinking to modify the runtime .java file as well, might be a bit trickier.
Here is what you need
Code:void GetAndroidManifestPathname(LPTSTR destPathname, LPCWSTR androidDirectoryPathname){ #ifdef _UNICODE _tcscpy_s(destPathname, _MAX_PATH, androidDirectoryPathname); #else WideCharToMultiByte(CP_ACP, 0, androidDirectoryPathname, -1, destPathname, _MAX_PATH, NULL, NULL); #endif int lg = _tcslen(destPathname); if ( lg == 0 ) return; if ( destPathname[lg-1] != '\\' ) _tcscat(destPathname, _T("\\")); _tcscat(destPathname, _T("AndroidManifest.xml")); } void GetProjectPropertiesPathname(LPTSTR destPathname, LPCWSTR androidDirectoryPathname) { #ifdef _UNICODE _tcscpy_s(destPathname, _MAX_PATH, androidDirectoryPathname); #else WideCharToMultiByte(CP_ACP, 0, androidDirectoryPathname, -1, destPathname, _MAX_PATH, NULL, NULL); #endif int lg = _tcslen(destPathname); if ( lg == 0 ) return; if ( destPathname[lg-1] != '\\' ) _tcscat(destPathname, _T("\\")); _tcscat(destPathname, _T("project.properties")); } LPSTR ReadTextFile(LPCTSTR destPathname) { LPSTR pData = NULL; FILE* f = _tfopen(destPathname, _T("r")); if ( f != NULL ) { fseek(f, 0, SEEK_END); long byte_length = ftell(f); pData = (LPSTR)calloc(byte_length+1, sizeof(char)); if ( byte_length != 0 && pData != NULL ) { fseek(f, 0, SEEK_SET); fread(pData, byte_length, 1, f); pData[byte_length] = 0; } fclose(f); } return pData; } void WriteTextFile(LPCTSTR destPathname, LPSTR pData) { FILE* f = _tfopen(destPathname, _T("w")); if ( f != NULL ) { UINT bsize = strlen(pData) * sizeof(char); if ( bsize != 0 ) fwrite(pData, bsize, 1, f); fclose(f); } } LPSTR InsertString(LPSTR pData, LPCSTR pStringToFind, LPCSTR pStringToInsert) { LPCSTR pFoundStr = strstr(pData, pStringToFind); if ( pFoundStr == NULL ) return pData; int newsize = strlen(pData) + strlen(pStringToInsert); LPSTR pNewData = (LPSTR)calloc(newsize+1, sizeof(char)); if ( pNewData == NULL ) return pData; int lgBeginning = (int)(pFoundStr - pData); memcpy(pNewData, pData, lgBeginning); strcpy(pNewData + lgBeginning, pStringToInsert); strcat(pNewData, pFoundStr); free(pData); return pNewData; } LPSTR AppendString(LPSTR pData, LPCSTR pStringToAdd) { int newsize = strlen(pData) + strlen(pStringToAdd); LPSTR pNewData = (LPSTR)calloc(newsize+1, sizeof(char)); if ( pNewData == NULL ) return pData; memcpy(pNewData, pData, strlen(pData)); strcat(pNewData, pStringToAdd); free(pData); return pNewData; }
I pasted all of your code.
but I dont know :how to trigger the methor of " PrepareAndroidBuild " ?
I don't find any where this method is called. so how to trigger this method? is it auto triggered?
thanks a lot.
It is called by the CF before compiling an android project.