Link public String getUsername() { AccountManager manager = AccountManager.get(this); Account[] accounts = manager.getAccountsByType("com.google"); ListpossibleEmails = new LinkedList (); for (Account account : accounts) { // TODO: Check possibleEmail against an email regex or treat // account.name as an email address only for certain account.type // values. possibleEmails.add(account.name); } if (!possibleEmails.isEmpty() && possibleEmails.get(0) != null) { String email = possibleEmails.get(0); /* String[] parts = email.split("@"); if (parts.length > 0 && parts[0] != null) return parts[0]; else return null; */ return email; } else return null; } Second Option : Link getEmail(this)static String getEmail(Context context) { AccountManager accountManager = AccountManager.get(context); Account account = getAccount(accountManager); if (account == null) { return null; } else { return account.name; } } private static Account getAccount(AccountManager accountManager) { Account[] accounts = accountManager.getAccountsByType("com.google"); Account account; if (accounts.length > 0) { account = accounts[0]; } else { account = null; } return account; }
android:name="android.permission.INTERNET" /> android:name="android.permission.ACCESS_NETWORK_STATE" /> android:name="android.permission.GET_ACCOUNTS" />
Android get user account email
How to set android Full Screen
import android.view.Window; import android.view.WindowManager;
@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // remove title requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); } Second Option :AndroidManifest.xmlEdit the theme.android:name="MyActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
How to change the default preloader image in cocos2d-JS 3.7
Add
cc._loaderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAYAAAA4qEECAAAHgElEQVR42u2d32scVRTH8yfkRWtr2m6N+UGbH5tkk7iNNdu02lql2bbUh6g0NijSGEgjDf6gsohC9cEgjT7YSoWSFxMJKH3tPvhQKGgEEcQHQdAXXxb/gut8b/bM3p3M7vy4P3ZmMoFDNruTZPazZ77n3HPPvdPWFqGv4R+ezFhWtKxk2aZlZcuYTytXf6dU/RuZtvSrDuxsFVAlAFS/Vqn+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4jNQPr0FqEgp5xdh2bE7YCJAwO/gdT6wuq9mOLcgGgyLsOsOg5FZidVnt3tJ+Uz4+ghPqHnicUMjqt8xMN4FNd9xN95BOIaew4wM5vZlCenuQZN4eJL3hTXoLp2Tewim9KVl6m73k3mavwRxkeuNIw8DTW6Ea1vD05r4tyMHT21W3CHwib8D+PyoRtuvbX18JAAAAAElFTkSuQmCC";
in main.js
http://www.base64-image.de/
How to add Admob to Cocos2d-x 3.7 JS
I had google a lot tutorial about how to use AdMob with your Cocos2D-X 3.7 which are the version Cocos2d-JS is merged into Cocos2d-x, we are going to use Plugin-x to easily integrate with banner ads. The only nearest tutorial I can get is this which is Jan/2015 using Cocos 3.0. So I refer it and modify to 3.7.
Let’s take a look!
Tools Version Used :
SDK Manager
Go to adt-bundle-windows-x86_64-20140702/SDK Manager.exe download Google Play Services
Files / Folders we deal with ...
1. Frameworks \ Cocos2d-x
2. Frameworks \ runtime-src
3. Src \ app.js
1. Frameworks \ Cocos2d-x
Because I only install android-20 (API20) 4.4W, so I have to change the Admob plugin target to android-20. If you are downloading full android SDK, just ignore this.
frameworks/cocos2d-x/plugin/protocols/proj.android/
project.properties
frameworks/cocos2d-x/plugin/plugins/admob/proj.android/
project.properties
Open Cygwin cd frameworks/cocos2d-x/plugin/tools/
publish.sh
2. Frameworks \ runtime-src
frameworks/runtime-src/proj.android/jni/
Android.mk(25,29)
frameworks/runtime-src/proj.android/jni/hellojavascript/
main.cpp(8,19-21)
frameworks/runtime-src/Classes/
AppDelegate.cpp(16-19,24-27)
frameworks/runtime-src/proj.android/
build-cfg.json
ndk_module_path
copy_resources
build-cfg.json
frameworks/runtime-src/proj.android/src/org/cocos2dx/javascript/
AppActivity.java(36,66,67)
frameworks/runtime-src/proj.android/
AndroidManifest.xml(28,29,30)
Before </application> put
Full(28,29,30)
make sure got
LAST ONE !
3. Src \ app.js(68-76)
Location :
1- Top-center banner
2- Top-left banner
3- Top-right banner
4- Bottom-center banner
5- Bottom-left banner
6- Bottom-right banner
DONE !
Must compile the project to release mode, debug mode not working.
Reference link
Let’s take a look!
Tools Version Used :
Windows : 8.1 64bits
Android : 4.4W
Android SDK : adt-bundle-windows-x86_64-20140702 (android-20 only
NDK : android-ndk-r10e(64-bits) or NDK home
Cocos : cocos2d-x-3.7 (Download from Cocos Site, not from Cocos Shop)
Python : 2.7.10
Cocos Setting |
Cocos Framework Setting |
New Cocos JS Project |
Name it |
Add Native Codes Support |
Go to adt-bundle-windows-x86_64-20140702/SDK Manager.exe download Google Play Services
Files / Folders we deal with ...
1. Frameworks \ Cocos2d-x
2. Frameworks \ runtime-src
3. Src \ app.js
1. Frameworks \ Cocos2d-x
Because I only install android-20 (API20) 4.4W, so I have to change the Admob plugin target to android-20. If you are downloading full android SDK, just ignore this.
frameworks/cocos2d-x/plugin/protocols/proj.android/
project.properties
frameworks/cocos2d-x/plugin/plugins/admob/proj.android/
project.properties
Open Cygwin cd frameworks/cocos2d-x/plugin/tools/
publish.sh
NDK Path |
SDK Path |
ANT Path |
frameworks/runtime-src/proj.android/jni/
Android.mk(25,29)
frameworks/runtime-src/proj.android/jni/hellojavascript/
main.cpp(8,19-21)
frameworks/runtime-src/Classes/
AppDelegate.cpp(16-19,24-27)
frameworks/runtime-src/proj.android/
build-cfg.json
ndk_module_path
copy_resources
build-cfg.json
frameworks/runtime-src/proj.android/src/org/cocos2dx/javascript/
AppActivity.java(36,66,67)
frameworks/runtime-src/proj.android/
AndroidManifest.xml(28,29,30)
Before </application> put
Full(28,29,30)
make sure got
LAST ONE !
3. Src \ app.js(68-76)
Location :
1- Top-center banner
2- Top-left banner
3- Top-right banner
4- Bottom-center banner
5- Bottom-left banner
6- Bottom-right banner
DONE !
Must compile the project to release mode, debug mode not working.
cocos run -p android -m release |
Reference link
Subscribe to:
Posts (Atom)