Friday, November 2, 2018

Appc is not recognized as an internal or external command

Try the following steps.

1.  uninstalled appcelerator (npm uninstall -g appcelerator).

2. Then uninstalled Node.

3. Also, delete any node directory to make sure any traces of Node was removed.

4. Reinstall Node - https://nodejs.org/en/#download

5. Reinstall appcelerator (npm install -g appcelerator)
6. Run - appc use latest -l trace

7. Run - appc setup -l trace


Hope this helps.

Tuesday, June 5, 2018

How to change action bar hamburger icon color.

You have to use a custom theme for changing the hamburger icon color. Here is the sample code and doc link

- https://gist.github.com/MotiurRahman/419344fbf8e9d4fb2aa262a4b9054743

- https://docs.appcelerator.com/platform/latest/#!/guide/Android_Action_Bar

Hope this helps.

Wednesday, April 4, 2018

Hyperloop: Example code for checking the notification is enabled or not.

After adding hyperloop module run the following sample code

////////

var Activity = require('android.app.Activity');
var activity = new Activity(Ti.Android.currentActivity);
var contextValue = activity.getApplicationContext();

var notification = require('android.support.v4.app.NotificationManagerCompat');

var notificationObject = notification.from(contextValue);


function doClick(e) {
alert(notificationObject.areNotificationsEnabled());

}

////

Thanks!

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!

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.