Appcelerator titanium push Notification using C2DM? - android

I am using Appcelerator Titanium Version 1.8.0 have anyone tried push notification using google's C2DM.if so help me to create Sample push notification.

It is not that difficult: Here is steps for it...
Clone project from github
Find build.properties
Modify all paths to fit the paths (and versions) in your environment
Optionally you need to download and install the android sdk from here http://developer.android.com/sdk/ndk/index.html
Open console in module root and type ant and hit enter
The build process should end with something like build successfully
In the module directory, you will find the build result in the dist folder
Open that folder, unzip the com.findlaw.c2dm-android-0.1.zip
A folder is created: modules/android/com.findlaw.c2dm/0.1
copy the content of modules/android/com.findlaw.c2dm/0.1 to the folder [your_project]/modules/android/com.findlaw.c2dm/
Copy timodule.xml to the root folder of your project (where the tiapp.xml is located)
Open tiapp.xml and replace all occurences of com.findlaw.c2dm with your app id, except of the line including this:
com.findlaw.c2dm.C2DMReceiver
Register the module in tiapp.xml:
<modules>
<module platform="android" version="0.1">com.findlaw.c2dm</module>
</modules>
14. Use the module in your code as described in the example of the module
For more check this communication of our team member...
Your Module folder should not inside the Resource folder

Related

Cordova plugin with precompiled .so files not loading onto the device

I'm using a 3rd party library that is for an Android app, but I need to use it in a Cordova plugin (Phonegap) and after I build/run debug running on the device, the logger is throwing an error about not being able to find the .so file. They use this file with JNI. How can I ensure that the files are being added to apk? Their documentation states that the files need to go in the libs directory like:
/libs/armeabi-v7a/<filename>.so
I've added them to this directory and it seems that only jar files are being added to the plugin. How can I get this file to load onto the device when building the plugin? I'm using Android Studio 0.3.6 with Android API level 19. ( I can't change the versions because that's what we currently support in our app)
Android studio opens by default in "Android view" wich can be quite confusing.
To change the view you click on the down arrow at the right of the word android just above your project content. If you switch to the project view, you will see something that will be less confusing for you and where what's displayed matches the file system structure.
Then you can copy your .so files in the libs/something folder (something being the name of the processor architecture).
If you switch back to the android view, you will see the file inside jniLibs.
Please pay attention to that topic How to include *.so library in Android Studio?. You need put the files into "app\src\main\jniLibs". In plugin.xml that looks like
<source-file src="src/android/armeabi-v7a/some_file.so" target-dir="app\src\main\jniLibs\armeabi-v7a" />

Android Studio creates app folder

I am working with Android Studio 1.1.0 on a MacBook Pro with OS X 10.9.5.
When I import projects (Eclipse) I find the source code is put under a folder named "app".
Ok, so far so good. The projects build and .apk files named app-debug.apk and app-debug-unaligned.apk are generated. They execute fine on the emulator and target device (Samsung Galaxy S5).
I wanted to rename the app folder as well as the .apk files.
The project name is tcpcommclient. I wanted to change the module name "app" to "TCP_Client". (not sure if I am allowed to do that).
I found the following in stackoverflow:
Why is my APK name generic?
Which said if I changed the folder name (app) I should also change settings.gradle. I did and that didn't work. I keep getting:
Error:Android Source Generator: [tcpcommclient] AndroidManifest.xml file not found
I looked through my project for instances of ":app" and found three of the:
workspace.xml
settings.gradle
app.imi
in which I changed to ":TCP_Client". I also notice that app.imi (should be manually renamed?) is still around under TCP_Client.
What also happens is that the folder "app" seems to be created by Android Studio even when I deleted it manually. Also another app.imi file is created there which contains the following text:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
It seems like somehow I have Android Studio configured for this project so that it wants to see the source and the AndroidManifest.xml under the "app" folder.
Is there a way to change the name "app" to another name (namely "TCP_Client") and have that be the name of the .apk file?
Thanks in advance.
Jim
To rename a module:
Rename the folder from app to TCP_Client
In settings.gradle, replace include ':app' by include ':TCP_Client'.
Then resync the project with the Gradle files.
This is because Android Studio is a stripped-down version of IntelliJ IDEA that only allows you to create Gradle projects, and the Gradle plugin is nowhere near ready for prime time.
The easiest thing to do is just use a mature product like IDEA or Eclipse. But if you must use Studio, it's useful to know that app is actually the name of the Gradle module that it creates without bothering to ask you for a name. If you want a different name, create another module with the name you want, then delete the app module.

How do I get Cordova 3.0 to recognize my own plugins in external project folders?

I am able to create a Cordova 3.0 project for Android using the platform specific tools (I tried the CLI approach but could not make it work). I added the standard core plugins using the plugman tool. My app's index.html and .js plugin files seem to be loading since I can see the start screen and do some basic things in the app. However, the advanced functions like calling out to the database and such are not working since these were implemented by me with my own custom plugins. These plugins exist in their project folders, and are added as library references in the main activity (the one I right click in Eclipse and select Debug as Android application). As such, they show up as .jar references in the Android Dependencies section of the Java Build Path for that specific project. I am about 90% certain my .js plugin files are correctly setup since I do have one plugin that is a package in the main activity's src tree. This is the only plugin that did work. When I removed that package to test and tried using that plugin functionality, it failed to work.
My plugins have been added correctly to the config.xml file. At least for the one custom plugin that exists in the main activity's src directory. Here is an example of a non-working plugin:
<feature name="DBHelper_Plugin">
<param name="android-package" value="com.cordova.plugin.dbhelper.DBHelper_Plugin" />
</feature>
Is it possible to use 3rd party plugins from external folders? If so, how? If not, do I have any alternative options other than cluttering up my main activity's src tree with a million plugin packages (as it is right now with the core plugins)?
For anyone who might also be having this issue, here is what I did:
Remove your external (outside of your main activity's src directory) plugins from the Android library references (right click main activity > Properties > Android > remove from Library section). Only do this for the plugin projects themselves.
Find your generated plugin .jar files in their bin directories in their respective project folders in Windows Explorer. If they are not there, build the projects in Eclipse. Drag these into the libs folder of your main activity. Eclipse will ask if you want to copy or link these files. Choose to link it.
And that's it. The plugins will now show under Android Private Libraries instead of Android Dependencies, and Cordova is able to see and use them (make sure to include them as feature references in your config.xml file). Since they are linked you can make changes to your plugin in Eclipse and not have to worry about copying it over again.
Cheers.

Creating a new Android Project in Terminal-IDE

Is there a script or something that creates a new Android project in Terminal IDE on Android? How does the R file get updated with new resources?
This might help : http://developer.android.com/tools/projects/projects-cmdline.html
It will create a project that can be used...with ant.
Maven has an archetype system that can create a new Android project : https://github.com/akquinet/android-archetypes
There doesn't seem to be any gradle equivalent (yet).
You need to create your project's home folder and then create the
./src
./dist
./res
./build
./build/classes
directories and add an "AndroidManifest.xml" file manually.
It works. Copy the "builder.sh" script in the project's home folder and make the proper changes like cd into your project's home folder, set your project's package name and select the main activity class.
As per your question about the R.java file, the aapt tool from Android SDK detects the changes in resources and writes R.java file and packs resources accordingly.

Android Library assets folder doesn't get copied

I am creating an Android library and it has an assets folder with images.
When I use it in another project the assets doesn't get copied.
Anyone else had this issue?
The new Android Build System that is based on Gradle supports asset folders in library projects!
With ANT based builds it's still not possible:
Library projects cannot include raw assets. (See docs)
But you could
copy the assets manually
or even patch the aapt tool (see http://devmaze.wordpress.com/2011/06/26/enabling-assets-in-android-libraries/)
It is possible to put assets into resulting library jar by small fix:
Put "custom_rules.xml" into you library project home (near the build.xml):
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<target name="-post-compile" if="${project.is.library}">
<echo>Post Compile: add assests from ${asset.absolute.dir} to ${out.library.jar.file}</echo>
<jar destfile="${out.library.jar.file}" update="true">
<zipfileset dir="${asset.absolute.dir}" prefix="assets" excludes="**/*.java ${android.package.excludes}"/>
</jar>
</target>
This will pack your library assets into you resulting library jar. As result, these assets will be included into resulting .apk of your application.
Checked on Android SDK Tools Revision 21.1.0 on OSX
From Eclipse and ANT you can reference the same "assets" folder from multiple projects.
This allows your source tree to have a single copy of the assets files, but have them included in multiple APKs.
See Android: targeted res folders for debugging in eclipse
From ProjectA I was able to reference ..\ProjectA\Assets from ProjectB.
On Eclipse (under Windows at least, I've not tried on Linux yet), I had to create a new variable to reference ..\ProjectA and use that variable in "Linked Folder Location". If I attempted to use ".." in "Linked Folder Location" eclipse wouldn't accept it.
For those using IntelliJ IDEA, you can make a change to your application module's packaging settings to include depedent assets. Note, this was done on version 14.0.2 of IntelliJ Community edition. My main application module now inherits files form my library project's assets folder as if they were right in the main project!
Right click application module > Open Module SEttings. Select Android tree node on module > Packaging Tab. Check "Include assets from dependencies into APK"
Note: I've never used Android Studio, but I would guess there is a similar setting for this in that application.
start by creating android lib project, close after creation. this'll prevert autobuild
use cmd terminal on windows android command is batch file
add tools to path
C:\Users\user_bss>PATH=%PATH%;C:\adt-bundle-windows-x86-20140321\sdk\tools
Generate build.xml for ant
android update project -p C:\Users\user_bss\Documents\Workspace\SDKAdvanced -n SDKAdvanced
notepad custom_rules.xml add the code from above don't forget end tag
run "ant debug" or "ant release" to build
you'll see classes.jar in bin dir this is your packed lib

Categories

Resources