最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - phonegap android camera: crash when "correctOrientation" option set - Stack Overflow

programmeradmin0浏览0评论

I know people have asked similar questions but I am having a serious issue.

anyone who uses phone gap knows it is definitely not the end all to solutions for an app!

but any way here is my code:

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI, 
correctOrientation: true });

the problem is when I add the correctOrientation, my freaking app has some sort of memory leak because it closes out and has an error. When i take out the correct orientation parameter, its fine, except for the fact that the orientation is wrong! does anyone have a work around to get my pictures' orientations correct?

<?xml version="1.0" encoding="utf-8"?>

     .0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.

-->

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />   
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />


<application android:icon="@drawable/icon" android:label="@string/app_name"
    android:hardwareAccelerated="true"
    android:debuggable="true">
    <activity android:name="mysecond" android:label="@string/app_name"
            android:theme="@android:style/Theme.Black.NoTitleBar"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>

I know people have asked similar questions but I am having a serious issue.

anyone who uses phone gap knows it is definitely not the end all to solutions for an app!

but any way here is my code:

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI, 
correctOrientation: true });

the problem is when I add the correctOrientation, my freaking app has some sort of memory leak because it closes out and has an error. When i take out the correct orientation parameter, its fine, except for the fact that the orientation is wrong! does anyone have a work around to get my pictures' orientations correct?

<?xml version="1.0" encoding="utf-8"?>

     http://www.apache/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.

-->

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />   
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />


<application android:icon="@drawable/icon" android:label="@string/app_name"
    android:hardwareAccelerated="true"
    android:debuggable="true">
    <activity android:name="mysecond" android:label="@string/app_name"
            android:theme="@android:style/Theme.Black.NoTitleBar"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>

Share Improve this question edited Jan 30, 2013 at 16:45 Dnaso asked Jan 30, 2013 at 16:08 DnasoDnaso 1,3654 gold badges22 silver badges48 bronze badges 11
  • I think you may be out of luck on this. – Pointy Commented Jan 30, 2013 at 16:16
  • @Dnaso may I see your manifest file? – Pratik Sharma Commented Jan 30, 2013 at 16:23
  • @Dnaso which cordova js version you are using? – Pratik Sharma Commented Jan 30, 2013 at 16:31
  • the manifest does have the camera permission I will append to my question and I am using 2.3.0. I figured since its out of beta it should be stable, I guess not :( – Dnaso Commented Jan 30, 2013 at 16:45
  • I didnt take out any of the permissions I am doing a kitchen sink project for someone, everything else is pretty good (sort of) but the camera and video are such a pain. – Dnaso Commented Jan 30, 2013 at 16:46
 |  Show 6 more ments

2 Answers 2

Reset to default 6

Thanks guys, I figured it out. You have to set the "target size" if you dont the img size is HUGE and will cause a memory overflow. I set the target width to 720 and the quality to 50, and all was well,

Are you using Phonegap's Hydration - I'm not 100% certain, but that seemed to make my camera app crash a few times. Removing that seemed to help. I've also tried adding targetWidth: 400 and turned Hydration back on, which seemed to work as well.

发布评论

评论列表(0)

  1. 暂无评论