Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Android Activity clarification

$
0
0

Hi there! I'm developing an Android mobile application with 3.1.3GA SDK version. I'm trying to click a button, open camera layer, take a picture and process data. This is my code:

var self = Titanium.UI.createWindow({
    fullscreen:true,
    navBarHidden:true,
    exitOnClose:true,
    backgroundColor:'white'
});
According to Appcelerator docs, with fullscreen, navBarHidden and exitOnClose parameters set true or false, self is an Heavyweight window, so is also an Activity.
var outfilepath = 'appdata://pic1.jpg';
var target = Ti.Filesystem.getFile(outfilepath);
 
var intent = Titanium.Android.createIntent({
    action:'android.media.action.IMAGE_CAPTURE'
});
intent.putExtraUri('output', target.getNativePath());
self.activity.startActivityForResult(intent, function(e) {
    if (e.resultCode === Titanium.Android.RESULT_OK) {
                var data = e.intent.data;
                var source = Ti.Filesystem.getFile(data);
 
            if ( !source.copy(target.getNativePath()) )
                alert("Copy failed!");
            else {
                currentlayer.image = target.read();
                outfilepath = 'appdata://';
                }           
                } 
 
});
This code give an exeption: e.intent.data is null. I don't understand: if self is an Heavyweight window, why intent is null? I've also tried this code:
var currActivity = Titanium.Android.currentActivity;
currActivity.startActivityForResult(intent, function(e) {
    if (e.resultCode === Titanium.Android.RESULT_OK) {
                var data = e.intent.data;
                var source = Ti.Filesystem.getFile(data);
 
            if ( !source.copy(target.getNativePath()) )
                alert("Copy failed!");
            else {
                currentlayer.image = target.read();
                outfilepath = 'appdata://';
                }           
                } 
 
});
With this code, nothing happens, except camera layer.

Can anyone explain me where I'm wrong? Thank you!


Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>