Android应用拍照后恢复到索引页 [英] Android app reverts back to index page after taking a picture
问题描述
所以我有这个程序,我建设,我是一个新手到Android应用。我使用PhoneGap的帮助使事情变得更容易。我用自己的例子,他们已经发布并拍摄照片时,应用程序恢复到我的应用程序的索引页,而不是去我想要的页面。
我想知道的是我在哪里可以修改code到另一个页面,并显示该图片只是我坐?
下面是我的一些code的:
<脚本SRC =PhoneGap的-1.1.0.js类型=文/ JavaScript的>< / SCRIPT>
< /头>
<脚本类型=文/ JavaScript的字符集=utf-8> VAR pictureSource; //图片来源
VAR destinationType; //设置返回值的格式 //等待PhoneGap的与设备连接
//
document.addEventListener(deviceready,onDeviceReady,FALSE); // PhoneGap的是随时可以使用!
//
功能onDeviceReady(){
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
} //如果照片是成功检索调用
//
功能onPhotoDataSuccess(为imageData){
//取消注释查看的base64 EN codeD图像数据
//执行console.log(为imageData); //获取图像句柄
//
变种smallImage =的document.getElementById('smallImage'); //取消隐藏图像元素
//
smallImage.style.display =块; //显示所拍摄的照片
//内联CSS规则是用来调整图像大小
//
smallImage.src =数据:图像/ JPEG; BASE64,+为imageData;
} //如果照片是成功检索调用
//
功能onPhotoURISuccess(imageURI){
//取消注释查看图像文件URI
//执行console.log(imageURI); //获取图像句柄
//
变种largeImage =的document.getElementById('largeImage'); //取消隐藏图像元素
//
largeImage.style.display =块; //显示所拍摄的照片
//内联CSS规则是用来调整图像大小
//
largeImage.src = imageURI;
} //一个按钮将调用这个函数
//
功能capturePhoto(){
//将图片使用设备的摄像头和图像检索为base64-CN codeD字符串
navigator.camera.getPicture(onPhotoDataSuccess,onFail,{质量:50});
} //一个按钮将调用这个函数
//
功能capturePhotoEdit(){
//将图片使用设备的摄像头,让编辑和图像检索为base64-CN codeD字符串
navigator.camera.getPicture(onPhotoDataSuccess,onFail,{质量:20,allowEdit:真});
} //一个按钮将调用这个函数
//
功能getPhoto(源){
//从指定源中检索图像文件位置
navigator.camera.getPicture(onPhotoURISuccess,onFail,{质量:50,
destinationType:destinationType.FILE_URI,
sourceType的:源});
} //调用如果有什么不好的事情发生。
//
功能onFail(消息){
警报('因为失败:'+消息);
} < / SCRIPT>
<身体GT;
< DIV数据角色=页面ID =选项数据主题=E>
< DIV数据角色=头的数据主题=E>
< H2类=longHeader UI标题>婚礼注册扫描仪< / H>
< / DIV>
< DIV数据角色=controlgroup>
< DIV数据角色=内容的数据主题=D>
&所述; A HREF =http://zxing.appspot.com/scan数据角色=按钮>&下; IMG SRC =图像/ upc.png>&下; / A>
&所述; A HREF =#的onclick =capturePhoto();数据角色=按钮>< IMG SRC =图像/ camera.png>< / A>
&所述; A HREF =manage.html数据角色=按钮>&下; IMG SRC =图像/ list.png>&下; / A>< / DIV>
< / DIV>< / DIV>
< DIV数据角色=页脚数据主题=E>
< H4类=smallFont> prejean IT解决方案2011&放大器;复制;< / H4>
< / DIV>
< DIV数据角色=页面ID =捕获数据主题=E>
< DIV数据角色=头的数据主题=E>
< H2类=longHeader UI标题>捕获照片< / H>< / DIV>
< DIV数据角色=内容的数据主题=D>
< IMG风格=显示:无;宽度:60像素,高度:60像素; ID =smallImageSRC =/>
< IMG风格=显示:无; ID =largeImageSRC =/>
< / DIV>
< / DIV>
编辑:
这是我的Android清单文件。
<活动机器人:名字=reg.scanner.DroidGap
机器人:标签=@字符串/ APP_NAME
机器人:configChanges =方向| keyboardHidden>
&所述;意图滤光器> &所述; /意图滤光器>
< /活性GT;
不是你code。
该错误是由写得不好的相机应用程序引起的。
试着安装一个不同的相机应用 - 我用相机去360
So i have this app i'm building and i'm a newbie to android apps. I am using phonegap to assist in making things easier. i used their example they have posted and when take the picture the app reverts back to the index page of my app instead of going to the page i want.
what i would like to know is where do i modify the code to go to another page and display the picture i just took?
here is some of my code:
<script src="phonegap-1.1.0.js" type="text/javascript"></script>
</head>
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for PhoneGap to connect with the device
//
document.addEventListener("deviceready",onDeviceReady,false);
// PhoneGap is ready to be used!
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64 encoded image data
// console.log(imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
// console.log(imageURI);
// Get image handle
//
var largeImage = document.getElementById('largeImage');
// Unhide image elements
//
largeImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
largeImage.src = imageURI;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 });
}
// A button will call this function
//
function capturePhotoEdit() {
// Take picture using device camera, allow edit, and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
<body>
<div data-role="page" id="option" data-theme="e">
<div data-role="header" data-theme="e">
<h2 class="longHeader ui-title">Wedding Registry Scanner</h2>
</div>
<div data-role="controlgroup">
<div data-role="content" data-theme="d">
<a href="http://zxing.appspot.com/scan" data-role="button"><img src="images/upc.png"></a>
<a href="#" onclick="capturePhoto();" data-role="button"><img src="images/camera.png"></a>
<a href="manage.html" data-role="button"><img src="images/list.png"></a>
</div>
</div>
</div>
<div data-role="footer" data-theme="e">
<h4 class="smallFont">Prejean IT Solutions 2011©</h4>
</div>
<div data-role="page" id="capture" data-theme="e">
<div data-role="header" data-theme="e">
<h2 class="longHeader ui-title">Capture Photo</h2></div>
<div data-role="content" data-theme="d">
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
<img style="display:none;" id="largeImage" src="" />
</div>
</div>
EDIT: this is in my android manifest file.
<activity android:name="reg.scanner.DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter> </intent-filter>
</activity>
Its not your code.
The error is caused by poorly written Camera application.
Try installing a different Camera App - I use Go Camera 360
这篇关于Android应用拍照后恢复到索引页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!