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();



Hope this helps.