Here is a sample code to do that
Thursday, March 15, 2018
Friday, March 9, 2018
How to choose a pdf/doc/image file from the device and upload to the server.
You can try with the following sample code
var window = Ti.UI.createWindow({
backgroundColor : 'red',
layout : "vertical"
});
// Create a Button.
var request = Ti.UI.createButton({
title : 'GO',
height : 100,
width : 100,
backgroundImage : "motiur.jpg",
top : 50
});
request.addEventListener('click', function(e) {
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_GET_CONTENT,
type : "application/pdf"
});
intent.addCategory(Ti.Android.CATEGORY_OPENABLE);
var x = Ti.Android.createIntentChooser(intent, "Select");
window.getActivity().startActivityForResult(x, function(e) {
//alert("fileData:" + JSON.parse(e.intent.data));
var doc = Ti.Filesystem.getFile(e.intent.data);
Ti.API.info(JSON.stringify(doc));
var file = Ti.Filesystem.getFile(doc.nativePath);
Ti.API.info("File:" + doc.nativePath);
alert("File path:" + doc.nativePath);
// write here http code for file uploading to the server.
});
});
window.add(request);
window.open();
Thanks!
var window = Ti.UI.createWindow({
backgroundColor : 'red',
layout : "vertical"
});
// Create a Button.
var request = Ti.UI.createButton({
title : 'GO',
height : 100,
width : 100,
backgroundImage : "motiur.jpg",
top : 50
});
request.addEventListener('click', function(e) {
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_GET_CONTENT,
type : "application/pdf"
});
intent.addCategory(Ti.Android.CATEGORY_OPENABLE);
var x = Ti.Android.createIntentChooser(intent, "Select");
window.getActivity().startActivityForResult(x, function(e) {
//alert("fileData:" + JSON.parse(e.intent.data));
var doc = Ti.Filesystem.getFile(e.intent.data);
Ti.API.info(JSON.stringify(doc));
var file = Ti.Filesystem.getFile(doc.nativePath);
Ti.API.info("File:" + doc.nativePath);
alert("File path:" + doc.nativePath);
// write here http code for file uploading to the server.
});
});
window.add(request);
window.open();
Thanks!
Thursday, February 22, 2018
Android: does not show the Map || How to create API key for map
Usually, Map does not show if your API key is not correct or Map module version is not compatible. So the following steps can help to generate the API key
Go to the following link and "Detailed guide for users of the standard Google Maps Android API" section
You have to create your API key with the exact package name (<id> tag value) and SHA-1 certificate fingerprint.
You can generate your SHA-1 certificate fingerprint using this command for the development App
- keytool -list -v -keystore ~/Library/Application\ Support/Titanium/mobilesdk/osx/7.0.2.GA/android/dev_keystore
No need password, just press enter.
For production App:
You have to use production keystore file for generating SHA-1 certificate fingerprint
- keytool -list -v -keystore <here drag and drop your keystore file then press enter>
Now, use that API key in your tiapp.xml file. You can follow this doc link to do that
Hope this helps
Monday, February 19, 2018
How to play an audio and video file using hyperloop.
Here is an example code for android
var Activity = require('android.app.Activity');
var AudioManager = require('android.media.AudioManager');
var MediaPlayer = require('android.media.MediaPlayer');
var Uri = require('android.net.Uri');
var activity = new Activity(Ti.Android.currentActivity);
var context = activity.getApplicationContext();
var mMediaPlayer;
var contentUri = Uri.parse('android.resource://' + activity.getPackageName() + '/raw/abc');
//var myUri = Uri.parse("app/platform/android/res/raw/five.mp3");
//Ti.API.info("myUri=" + myUri);
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener({
onCompletion : function(mediaPlayer) {
Ti.API.info('MediaPlayer playback completed');
}
}));
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setDataSource(context, contentUri);
mMediaPlayer.prepare();
function startMedia() {
mMediaPlayer.start();
}
function stopMedia() {
mMediaPlayer.pause();
// NOTE: You can also stop it, but then you have to prepare() it again as well
// mMediaPlayer.stop();
// mMediaPlayer.prepare();
}
$.win1.open();
Git link: https://github.com/appcelerator/hyperloop-examples/commit/d983520db7f10d2ad5209fce09b9f560621aa1f3
For Video file: https://github.com/appcelerator/hyperloop-examples/blob/master/app/controllers/android/videoplayer.js
Hope this helps.
Thursday, December 14, 2017
How to send push notification using PHP server.
Please take a look following sample code to do that
- https://gist.github.com/MotiurRahman/4ba3ff893ba38b3884c1
Hope this helps.
- https://gist.github.com/MotiurRahman/4ba3ff893ba38b3884c1
Hope this helps.
Friday, December 1, 2017
Arrow CRUD operation using custom object
Please take a look following GitHub link for ArrowDB CRUD operation
- https://gist.github.com/MotiurRahman/86a57d86fde36dcfe6044a402564b834
Hope this helps.
- https://gist.github.com/MotiurRahman/86a57d86fde36dcfe6044a402564b834
Hope this helps.
Saturday, November 4, 2017
Android Action Bar icon | Search Bar on Action Bar | Menu Item ! TableView Search
Hear is a sample code to do that
- https://gist.github.com/MotiurRahman/5ecc0f775d81defbdecf34192bf057d3
Hope this helps.
- https://gist.github.com/MotiurRahman/5ecc0f775d81defbdecf34192bf057d3
Hope this helps.
Monday, October 16, 2017
How to open pdf file on Android.
Following example would be helpful for opening pdf file
////////------////////////
var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "test.pdf");
var outFile = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'tempFile.pdf');
var outPath = outFile.nativePath;
file.copy(outPath);
try{
Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: 'application/pdf',
data: outPath
}));
} catch(e) {
alert('You must install a PDF reader to view this file');
}
OR
try{
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_VIEW,
type : "application/pdf",
data: outPath
});
var open = Ti.Android.createIntentChooser(intent, L('open_intent'));
Ti.Android.currentActivity.startActivity(open);
} catch(e) {
alert('You must install a PDF reader to view this file');
}
file = null;
Thanks
////////------////////////
var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "test.pdf");
var outFile = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'tempFile.pdf');
var outPath = outFile.nativePath;
file.copy(outPath);
try{
Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: 'application/pdf',
data: outPath
}));
} catch(e) {
alert('You must install a PDF reader to view this file');
}
OR
try{
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_VIEW,
type : "application/pdf",
data: outPath
});
var open = Ti.Android.createIntentChooser(intent, L('open_intent'));
Ti.Android.currentActivity.startActivity(open);
} catch(e) {
alert('You must install a PDF reader to view this file');
}
file = null;
Thanks
Friday, October 13, 2017
Sunday, July 30, 2017
CRUD operation for SQLight DataBase
Please take a look following GitHub link for SQLight database
- https://gist.github.com/MotiurRahman/5ecc0f775d81defbdecf34192bf057d3
Hope this helps.
Let me know if you have any question.
- https://gist.github.com/MotiurRahman/5ecc0f775d81defbdecf34192bf057d3
Hope this helps.
Let me know if you have any question.
Subscribe to:
Posts (Atom)