Android external activity fails - java

I'm trying to set up android multiple file chooser from https://github.com/paulasiimwe/Android-Multiple-file-Selector-Dialog.
I've added dependency to this library from my project.
Problem is app just fails when I click "run as android application".
Log:
[2015-01-30 01:55:19 - PhotoSigner] Android Launch!
[2015-01-30 01:55:19 - PhotoSigner] adb is running normally.
[2015-01-30 01:55:19 - PhotoSigner] Performing com.vladimir.photosigner.MainActivity activity launch
[2015-01-30 01:55:19 - PhotoSigner] Automatic Target Mode: using device 'HT17MV800004'
[2015-01-30 01:55:19 - PhotoSigner] Uploading PhotoSigner.apk onto device 'HT17MV800004'
[2015-01-30 01:55:26 - PhotoSigner] Failed to install PhotoSigner.apk on device 'HT17MV800004': timeout
[2015-01-30 01:55:26 - PhotoSigner] Launch canceled!
Here is my android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com`enter code here`.vladimir.photosigner"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<activity android:name="paul.arian.fileselector.FileSelectionActivity" />
<activity android:name="paul.arian.fileselector.FolderSelectionActivity" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.vladimir.photosigner.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>
</application>
</manifest>
And my code calling external activity:
import paul.arian.fileselector.FileSelectionActivity;
...
setContentView(R.layout.activity_main);
Intent intent = new Intent(getBaseContext(), FileSelectionActivity.class);
startActivityForResult(intent, 0);
...
onActivityResult is exactly same as man said in https://github.com/paulasiimwe/Android-Multiple-file-Selector-Dialog.
Could anyone help with that?

Related

The app works fine on AVD, but not on real device

I really have very big problem with my project. When my phone is connected to the computer via USB cable, everything works fine, but when the phone is disconnected the app doesn't work as I expected. So, I have already tried with android.os.Debug.waitForDebugger(), I removed the all #SuppressLint("NewApi"), also USB debugger is activated on my phone, but I think the problem can be in the Manifest file. Can someone tell me, what can be done in this case?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/fritz_logo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:windowSoftInputMode="adjustPan"
android:name="com.example.androproject.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/ThemeWithCorners"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.androproject.RegisterDnsAndUser"
android:screenOrientation="portrait"
android:theme="#style/ThemeWithCorners"
android:configChanges="keyboardHidden|orientation"/>
<activity
android:name="com.example.androproject.MenuApp"
android:screenOrientation="portrait"
android:theme="#style/ThemeWithCorners"
android:configChanges="keyboardHidden|orientation"/>
</application>
</manifest>
I am using the following, handler code. When I put 40000 ms, the app works, but when I put 60000 ms, my application doesn't work if the cable is disconnected.
handler.postDelayed(myRunnable = new Runnable(){
#Override
public void run() {
if(btnToggle.isChecked()){
btnToggle.setChecked(false);
btnToggleTimer.setChecked(false);
}else{
btnToggle.setChecked(true);
btnToggleTimer.setChecked(false);
}
}
}, min*60000);
Most likely you have enabled the "Stay awake"-mode in the Developer options in the settings menu. When you disconnect the phone from the charger it will go into sleep mode after a few seconds.
The solution is to either use a partial wake-lock using the PowerManager or (in the above case) use a PendingIntent and the AlarmManager to trigger a event at a later time.

Android (Eclipse) cannot find google-play-services_lib.apk tried multiple solutions

I am creating an android application that displays a map based on the Google maps API, which should be compatible with android 2.3 API level 10.
I have tried all the solutions i could come across such as:
imported existing code into my project (checked copy to workspace and its the directory google-play-services-lib)
added the correct meta and such in my XML (see below)
I have tried setting up the emulator with several different settings
The android application runs fine, but when this page is shown is exits.
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dcs.aber.ac.uk.cs211.group02"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="22" />
<permission
android:name="dcs.aber.ac.uk.cs211.group02.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<!-- Accessing camera hardware -->
<!-- putting android.hardware.camera prevents non-camera devices using this app -->
<uses-feature android:name="android.hardware.camera" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="dcs.aber.ac.uk.cs211.group02.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="dcs.aber.ac.uk.cs211.group02.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:logo="#drawable/ic_launcher"
android:theme="#style/AppTheme" >
<activity
android:name="dcs.aber.ac.uk.cs211.group02.StartScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="dcs.aber.ac.uk.cs211.group02.CreateWalkActivity"
android:label="#string/title_activity_create_walk" >
</activity>
<activity
android:name="dcs.aber.ac.uk.cs211.group02.HelpScreen"
android:label="#string/title_activity_help_screen" >
</activity>
<activity
android:name="dcs.aber.ac.uk.cs211.group02.WalkRecording"
android:label="#string/title_activity_walk_recording" >
</activity>
</application>
<meta-data android:name="dcs.aber.ac.uk.cs211.group02.API_KEY"
android:value="AIzaSyBKYpKfU4zn-3IBkskKsLbwRsQ1-IqFldk"
/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</manifest>
The xml displaying the map:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
tools:context=".WalkRecording" >
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/mapView"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
the java code for the map class
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class WalkRecording extends FragmentActivity {
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_walk_recording);
map=((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.mapView)).getMap();
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.walk_recording, menu);
return true;
}
}
The eclipse trace:
[2013-11-22 23:03:07 - WalkingTours] ------------------------------
[2013-11-22 23:03:07 - WalkingTours] Android Launch!
[2013-11-22 23:03:07 - WalkingTours] adb is running normally.
[2013-11-22 23:03:07 - WalkingTours] Performing dcs.aber.ac.uk.cs211.group02.StartScreen activity launch
[2013-11-22 23:03:07 - WalkingTours] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'mapTestAPI16'
[2013-11-22 23:03:07 - WalkingTours] Uploading WalkingTours.apk onto device 'emulator-5554'
[2013-11-22 23:03:07 - WalkingTours] Installing WalkingTours.apk...
[2013-11-22 23:03:12 - WalkingTours] Success!
[2013-11-22 23:03:12 - google-play-services_lib] Could not find google-play-services_lib.apk!
[2013-11-22 23:03:12 - WalkingTours] Starting activity dcs.aber.ac.uk.cs211.group02.StartScreen on device emulator-5554
[2013-11-22 23:03:14 - WalkingTours] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=dcs.aber.ac.uk.cs211.group02/.StartScreen }
Seeing your error log, there is one solution provided in this link. Dont import google-play-services_lib APK, you should reference it on your project as an Android Library Project.
I had the same problem.
Look at project: Properties-> Java Build Path under projects remove google-play-services_lib.
Not necessary to include in build also as a project.

Android "Hello World" Error

I'm new to Android development. I'm running Eclipse with the ADT plugin and installed all the necessary dependencies. I open up Eclipse, select 'New Android Applciation' and everything is set. When I run the app, I get an error message saying
/home/parallels/workspace/test/AndroidManifest.xml: 2: /home/parallels/workspace/test/AndroidManifest.xml: Syntax error: newline unexpected
So I look in Android Manifest and it's just the default, Eclipse generated code, right? What's the problem here?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.test.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>
</application>
</manifest>
Is there any empty space above your first line in your manifest? That has to be at the very top. Also have you compiled anything successfully thus far? Maybe something didn't get imported properly. I recommend android studio. It's just Googles modified version of eclipse that specializes in android development. It comes with everything you need all ready to go.

Android Bluetooth_admin permission error

Regarding Android bluetooth discovery.
Getting this error from manifest permission error. However, the only errors that I found posted, was that they forgot to put the permission outside the application. This is however not the case here.
The program is tested on a Galaxy S2 running Jelly Bean 4.1.
The error is as follows:
03-19 13:08:03.933: W/dalvikvm(12616): threadid=1: thread exiting with uncaught exception (group=0x413082a0)
03-19 13:08:03.938: E/AndroidRuntime(12616): FATAL EXCEPTION: main
03-19 13:08:03.938: E/AndroidRuntime(12616): java.lang.SecurityException: Need BLUETOOTH_ADMIN permission: Neither user 10004 nor current process has android.permission.BLUETOOTH_ADMIN.
Basically the manifest looks like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.motioncontrol"
android:versionCode="1"
android:versionName="1.0" >
<user-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:debuggable="true"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.motioncontrol.Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AccelerometerDat"
android:label="#string/accelerator_title" />
<activity
android:name=".GyroscopeData" />
<activity
android:name=".Gravitydat" />
<activity
android:name=".Linearacc" />
<activity
android:name=".Bluetooth" />
<activity
android:name=".CheckBluetooth" />
<activity
android:name=".About"
android:label="#string/about_title"
android:theme="#android:style/Theme.Dialog" />
</application>
</manifest>
And the class where the error occurs:
private void doDiscovery() {
if (D) Log.d(TAG, "doDiscovery()");
// Indicate scanning in the title
setProgressBarIndeterminateVisibility(true);
setTitle(R.string.scanning);
Log.d(TAG, "indicates scanning");
// Turn on sub-title for new devices
findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
Log.d(TAG, "Set up sub-title for new devices");
// If we're already discovering, stop it
if (mBtAdapter.isDiscovering()) {
mBtAdapter.cancelDiscovery();
Log.i(TAG, "Already running discovering, stop it!");
}
// Request discover from BluetoothAdapter
mBtAdapter.startDiscovery();
Log.d(TAG, "Request discover form BluetoothAdapter");
}
Hope for an answer, what is going wrong :).
Thanks!
Change
<user-permission android:name="android.permission.BLUETOOTH_ADMIN" />
to
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<user-permission> is used to regulate the access to the current component by other application. You should try <uses-permission> to get the privilege.

See only home screen and not my app when running the App

I'm really freaking out of this problem, I've tried anything. Nothing works. When I run the app, android emulator just loads, shows the home screen and then nothing happens (I don't see my app running), just nothing. What should I do?
EDIT: Console code shows:
[2012-07-04 00:20:17 - MyAPPP] Android Launch!
[2012-07-04 00:20:17 - MyAPPP] adb is running normally.
[2012-07-04 00:20:17 - MyAPPP] Performing com.exame.myappp.MainActivity activity launch
[2012-07-04 00:20:17 - MyAPPP] Automatic Target Mode: launching new emulator with compatible AVD 'MonoForAndroid_API_8'
[2012-07-04 00:20:17 - MyAPPP] Launching a new emulator with Virtual Device 'MonoForAndroid_API_8'
LogCat doesn't show anything
EDIT2: Manifest as requested :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exame.myappp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
this could be an issue with Eclipse, sometimes when I run eclipse I have the same problem where the emulator runs, my app fails to run and when I try to run the app again I have a new emulator running. What I usually find myself doing is build/clean the project, restart eclipse and then start again.
Sorry for the old techie "off/on" answer, hope it sorts itself out.
Make your manifest look like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exame.myappp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Categories

Resources