I currently have this code(and I've tried various others) at the bottom of my app for detecting orientation change:
function orientation_changed (){
if ( is_portrait() )
{
alert('ABC');
}
else if ( is_landscape() )
{
alert('234');
}
clearTimeout(window.t);
delete window.t;
}
window.t = undefined;
window.onorientationchange = function (event)
{
window.t = setTimeout('orientation_changed();', 250);
}
function is_landscape()
{
var uagent = navigator.userAgent.toLowerCase();
if ( uagent.search('ipad') > -1 )
{
var r = ( window.orientation == 90 || window.orientation == -90 );
}
else
{
var r = ( screen.width > screen.height );
}
return r;
}
function is_portrait()
{
var uagent = navigator.userAgent.toLowerCase();
if ( uagent.search('ipad') > -1 )
{
var r = ( window.orientation == 0 || window.orientation == 180 );
}
else
{
var r = ( screen.width < screen.height );
}
return r;
}
But it never fires. I've tried other ways of getting the change in orientation of my tablet but none seem to work. My manifest looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="com.pp.editable" android:versionName="1.1" android:versionCode="5" android:hardwareAccelerated="true">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<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.INTERNET" />
<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.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<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="editabledelights" 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="7" android:targetSdkVersion="17"/>
</manifest>
And I am using a Lenovo IdeaPad. I'm using JQuery mobile and Cordova 2.3.0. Am I doing something wrong?
This is because you have added "sceenSize" attribute just remove that
I feel dumb. On Lenovo, its set to portrait only in the system setting :P. Had to enable orientation switching.
you are probably forgetting to add the event listener for detecting the orientation change.
// attach the onOrientationChange event listener in your script tag
window.addEventListener( 'onorientationchange', OnOrientationChange, false );
Hope that helps.
Related
I am unable to export the SQLite data in to csv file.i am unable to see any LOGCAT also. Necessary permissions are granted in Manifest file. could you check and sharp wit your expertise.
Also opencsv and other supporting files are loaded.
Manifest file. Attaching with Manifest file,Mainactivity data for your kind review,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.bar.example.myapplication">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="#style/AppTheme">
<activity android:name=".CourseSearchActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ScanActivity" />
</application>
</manifest>
Mainactivity.
btnexport.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
SQLiteDatabase db = openOrCreateDatabase("OCC", MODE_PRIVATE, null);
File exportDir = new File(getExternalFilesDir(null), "");
if (!exportDir.exists()) {
exportDir.mkdirs();
}
File file = new File(exportDir, "coke.csv");
try {
file.createNewFile();
com.bar.example.myapplication.CSVWriter csvWrite = new com.bar.example.myapplication.CSVWriter(new FileWriter(file));
Cursor curCSV = db.rawQuery("SELECT * FROM DATAALL", null);
csvWrite.writeNext(curCSV.getColumnNames());
while (curCSV.moveToNext()) {
//Which column you want to export
String arrStr[] = {
curCSV.getString(curCSV.getColumnIndex("_id")),
curCSV.getString(curCSV.getColumnIndex("Material_Barcode")),
curCSV.getString(curCSV.getColumnIndex("Material_Number")),
curCSV.getString(curCSV.getColumnIndex("Material_Description")),
curCSV.getString(curCSV.getColumnIndex("Scanning_Date")),
curCSV.getString(curCSV.getColumnIndex("Production_Date")),
curCSV.getString(curCSV.getColumnIndex("Expiry_Ratio")),
curCSV.getString(curCSV.getColumnIndex("Product_Durablity")),
curCSV.getString(curCSV.getColumnIndex("Qty")),
};
csvWrite.writeNext(arrStr);
}
csvWrite.close();
curCSV.close();
Toast.makeText(getApplicationContext(), "Downloaded Successfully", Toast.LENGTH_SHORT).show();
} catch (Exception sqlEx) {
Log.e("ResultActivity", sqlEx.getMessage(), sqlEx);
}
}
});
I am trying to use the device camera in my application , but there is an error shows up and the camera is not shown.
The error is
unable to create file for local storage
My Controller code is
function choosePhotoDialogClicked(e) {
if (Ti.Media.hasCameraPermissions) {
openCamera();
}else {
alert("No camera permission. Asking for Permission");
Ti.Media.requestCameraPermissions(function(e) {
alert('request result'+JSON.stringify(e));
if (e.success === true) {
openCamera();
} else {
alert("Access denied, error: " + e.error);
}
});
}
}
function openCamera(){
Ti.Media.showCamera({
allowEditing: true,
saveToPhotoGallery: true,
mediaTypes: [Titanium.Media.MEDIA_TYPE_PHOTO],
success: function(event) {
writeFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory, 'ana.png');
writeFile.write(event.media);
$.addNewPhoto.setTitle('اضافة صورة اخرى');
},
error: function(error) {
alert('showcamera error ->'+JSON.stringify(error));
//alert('خطأ في اعدادات الكاميرا');
}
});
}
and the tiapp.xml manifist code
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application>
<activity
android:name="ti.modules.titanium.media.TiCameraActivity"
android:configChanges="keyboardHidden|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</application>
<application android:theme="#style/Light"/>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23"/>
</manifest>
</android>
Any help will be appreciated
It's an issue with Android Permissions, Fokke and the team did a blog on this a few months ago for Marshmallow.
My onReceive() doesn't get invoked at all even when application receives sms message. It doesn't get invoked when the message arrives. Shouldn't it be working in background and only gets invoked when the SMS arrives?
It works fine on a seperate project but not when I'm integraing to my own app.
My Code:
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
public class SmsBroadcastReciever extends BroadcastReceiver {
private static final String LOG_TAG = "SMSBroadRec";
public static final String SMS_BUNDLE = "pdus";
String SenderNo = "+92----------";
String SenderNo2 = "+92----------";
#Override
public void onReceive(Context context, Intent intent) {
Log.d(LOG_TAG, "In onReceive()");
Bundle bundle = intent.getExtras();
String smsBody;
String address;
try {
if ( !bundle.isEmpty() ){
Log.d(LOG_TAG, "Sms received");
String verificationCode = null;
Object[] sms = (Object[]) bundle.get(SMS_BUNDLE);
for (Object sm : sms) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sm);
smsBody = smsMessage.getMessageBody();
address = smsMessage.getOriginatingAddress();
Log.d(LOG_TAG, address);
if (SenderNo.equals(address) || SenderNo2.equals(address)) {
verificationCode = getVerificationCode(smsBody);
Log.e(LOG_TAG, "OTP received: " + verificationCode);
break;
} else {
Log.d(LOG_TAG, "wrong sender");
break;
}
}
SharedPreferences prefs = context.getSharedPreferences(AppConfig.APP_SCRATCH, Context.MODE_PRIVATE);
SharedPreferences.Editor ed = prefs.edit();
ed.putString(AppConfig.APP_SCRATCH, verificationCode);
if (ed.commit()) {
Log.d(LOG_TAG, "commit succesful"); //added to the shared preferences
} else {
Log.d(LOG_TAG, "commit unsuccessful");
}
} else {
Log.d(LOG_TAG, "Intent must be empty!");
}
}
catch (Exception e){
e.printStackTrace();
}
}
private String getVerificationCode(String message) {
String code = null;
int index = message.indexOf(AppConfig.OTP_DELIMITER);
if (index != -1) {
int start = index + 2;
int length = 8;
code = message.substring(start, start + length);
return code;
}
return code;
}
}
This is the part of the manifest file and i have added permissions too which are READ_SMS, RECEIVE_SMS, WRITE_SMS.
manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ubroadkast.nayatel"
android:versionCode="4"
android:versionName="1.3">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.telephony"
android:required="true" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission
android:name="android.permission.INTERNET"
android:required="true" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:required="true" />
<uses-permission
android:name="android.permission.RECORD_AUDIO"
android:required="true" />
<uses-permission
android:name="android.permission.CAMERA"
android:required="true" />
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.SEND_SMS"
android:required="true" />
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.CHANGE_WIFI_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.READ_CONTACTS"
android:required="true" />
<uses-permission
android:name="android.permission.WRITE_CONTACTS"
android:required="true" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:required="true" />
<uses-permission android:name="android.permission.WRITE_SMS"
android:required="true"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"
android:required="true"/>
<uses-permission android:name="android.permission.READ_SMS"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Ubroadkast">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider912845522101212"
android:exported="true" />
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:screenOrientation="landscape" />
<activity
android:name=".Home"
android:label="#string/app_name"
android:screenOrientation="portrait" />
<activity
android:name=".Settings"
android:label="Settings"
android:screenOrientation="portrait" />
<activity
android:name=".UserStatus"
android:label="#string/title_activity_user_status" />
<activity
android:name=".login"
android:label="#string/app_name"
android:screenOrientation="portrait" />
<activity
android:name=".SplashScreen"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".facebook"
android:label="UBroadkast Facebook Sign In"
android:screenOrientation="portrait" />
<activity
android:name=".Terms"
android:label="Terms And Conditions"
android:screenOrientation="portrait" />
<activity
android:name=".Signup"
android:label="Sign Up"
android:screenOrientation="portrait" />
<activity
android:name=".rating"
android:label="Ubroadkast Feedback"
android:screenOrientation="portrait" />
<activity
android:name=".change_password"
android:label="Reset Password" />
<activity android:name=".HomeScreen" />
<activity android:name=".Videoview" />
<activity android:name=".URLExtractor" />
<receiver android:name=".SmsBroadcastReciever" android:enabled="true" android:exported="false">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECIEVED"/>
</intent-filter>
</receiver>
</application>
</manifest>
change following line in manifest from
<action android:name="android.provider.Telephony.SMS_RECIEVED"/>
to
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
There's a spelling mistake of word "received".
While trigger Push Notification from WebService to my Mobile, am getting this error in my Eclipse Log. like this..
03-02 16:14:41.839: V/GCMBroadcastReceiver(28046): onReceive:
com.google.android.c2dm.intent.RECEIVE 03-02 16:14:41.839:
V/GCMBroadcastReceiver(28046): GCM IntentService class:
com.gcm.gcmtest.GCMIntentService 03-02 16:14:41.839:
V/GCMBaseIntentService(28046): Acquiring wakelock Unable to start
service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10
pkg=com.gcm.gcmtest
cmp=com.gcm.gcmtest/com.activate.gcm.GCMIntentService (has extras) }
U=0: not found
My Program:
Context mContext = MainActivity.this;
GoogleCloudMessaging gcm;
String gcmRegId;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
registerPushNotifInBackground();
}
private void registerPushNotifInBackground() {
new AsyncTask<Void, Void, String>() {
#Override
protected String doInBackground(Void... params) {
gcm = GoogleCloudMessaging.getInstance(mContext);
String msg = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(mContext);
}
Log.v("gcm", "---GCMRegistrar.isRegistered(mContext):"
+ GCMRegistrar.isRegistered(mContext));
gcmRegId = GCMRegistrar.getRegistrationId(mContext);
Log.v("gcm", "---GCMRegistrar.getRegistrationId(mContext):"
+ gcmRegId);
if (gcmRegId.equals("")) {
Log.v("gcm",
"---------if.. gcm.register:GCMIntentService.SENDER_ID:"
+ GCMIntentService.SENDER_ID);
gcmRegId = gcm.register(GCMIntentService.SENDER_ID);
} else {
Log.v("gcm",
"----else---GCMRegistrar.getRegistrationId...-");
gcmRegId = GCMRegistrar.getRegistrationId(mContext);
}
Log.v("gcm", "----------------regId:" + gcmRegId);
} catch (Exception ex) {
ex.printStackTrace();
Log.v("gcm",
"----------------ex:" + ex.getLocalizedMessage());
}
return msg;
}
#Override
protected void onPostExecute(String msg) {
}
}.execute(null, null, null);
}
Manifest Permission :
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<permission
android:name="com.gcm.gcmtest.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.gcm.gcmtest.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.gcm.gcmtest.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.gcm.gcmtest" />
</intent-filter>
</receiver>
<service
android:name="com.gcm.gcmtest.GCMIntentService"
android:enabled="true" />
</application>
Kindly help me in this problem.. i am working in the hybrid android mobile application.. it works correctly but when i changed the orientation the application gets restarted.... both in portrait and landscape...
This is my manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<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:allowBackup="true"
android:icon="#drawable/icon_dropin"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.cogzidel.dropinn.MainActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:label="#string/app_name"
android:screenOrientation="sensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
This is my mainActivity:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen",R.drawable.loading_img);
super.init();
if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
fixJellyBeanIssues();
}
super.loadUrl("file:///android_asset/www/index.html",8000);
}
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
}
#TargetApi(16)
protected void fixJellyBeanIssues() {
System.out.println(super.appView.toString());
try {
super.appView.getSettings().setAllowUniversalAccessFromFileURLs(true);
} catch(NullPointerException e) {
System.out.println(e.toString());
}
}
// catch an error and if try again 1x or quit
#Override
public void onReceivedError( int errorCode, String description, String failingUrl)
{
if(retryCount < 3) {
retryCount++;
System.out.println("Connection failed, trying again. Retry Count: "+retryCount);
super.loadUrl("file:///android_asset/www/listspace.html");
} else {
System.out.println("Sorry, it failed three times so I give up.");
super.loadUrl("file:///android_asset/www/fail.html");
}
return;
}
}
If don't want your application to restart you have to declare that explicidly in the android manifest like this
<activity android:name=".MyActivity"
android:configChanges="orientation"
android:label="#string/app_name">
However this is not recommended and considered as last resort.
Here you can read more how you should handle configuration changes
http://developer.android.com/guide/topics/resources/runtime-changes.html