i have problem
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
--->Could not connect to remote process. Aborting debug session.
I did
--->adb kill-server && adb start-server
--->invalidate cache / restart
but not work yet
image1:--> [1]: https://i.stack.imgur.com/HZF5D.png
image2:--> [2]: https://i.stack.imgur.com/hrE4a.png
I don't know why, but I was able to solve this by setting android:exported = "true" for the first Activity to launch.
<activity
android:name = ".ui.top.TopActivity"
android:exported = "true"
android:label = "#string/app_name">
<intent-filter>
<action android:name = "android.intent.action.MAIN" />
<category android:name = "android.intent.category.LAUNCHER" />
</ intent-filter>
</ activity>
Related
My Mobile version is 12. Work App properly but I upgrade my software version of mobile then crushes.
Show this Error on my log:
2022-03-01 12:04:55.025 31242-31291/com.Solver.Solver E/AndroidRuntime: FATAL EXCEPTION: WorkManager-WorkManagerTaskExecutor-thread-0
Process: com.Solver.Solver, PID: 31242
java.lang.IllegalArgumentException: com.Solver.Solver: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:147)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:124)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:79)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
I am solved this error.
I Implements this code.
implementation "androidx.work:work-runtime:2.7.1"
Your passing unexpected flags into a PendingIntent.
For example:
int intentFlags = PendingIntent.FLAG_ONE_SHOT;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
intentFlags = PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_IMMUTABLE;
}
After several attempt to fix this, i gave up and try to contact Qiscus. And they release new version that handle this Pending Intent behaviour change. So if anyone use Qiscus and got this error, you can use latest tag
https://github.com/qiscus/qiscus-sdk-android/releases/tag/1.3.35
PendingIntent pendingIntent;
Intent openIntent = new Intent(context, QiscusPushNotificationClickReceiver.class);
openIntent.putExtra("data", comment);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
pendingIntent = PendingIntent.getBroadcast(context, QiscusNumberUtil.convertToInt(comment.getRoomId()),
openIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
} else {
pendingIntent = PendingIntent.getBroadcast(context, QiscusNumberUtil.convertToInt(comment.getRoomId()),
openIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have an android app that does not require a log in, but I do have Anonymous sign-in enabled so that I can retrieve the userID from Firebase and use it to log specific events. I have the feeling that it just stopped retrieving the UID from Firebase.
What I've done to resolve the issue is the following:
updated all the dependencies
updated the emulator
Installed a new emulator
re-added the google services plugin
re-added google-services.json file
updated Android Manifest
I've tried to create a login-activity for the sake of testing, where through a button with an onclicklisterer, the user get's anoynmously logged in.
I've doubled checked Local History in Android Studio to see whether big changes were made to the code, not the case. See screenshot
Enabled and disabled anonymous login from the Firebase Console.
Re-written the entire code based on documentation from Firebase.
I've basically tried every solution there is
My Manifest
<?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.superawesome.metime">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/wazzup"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Cardview" />
<activity android:name=".cardviewactivity" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxx" />
<activity
android:name=".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>
<activity
android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
tools:replace="android:launchMode"
android:launchMode="standard" />
<service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
My code:
#Override
public boolean onOptionsItemSelected(#NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true; // go back to the first screen
case R.id.cardoverview:
startActivity(new Intent(this, cardviewactivity.class));
return true; //go to the screen where all the swiped right activities are stored
}
return super.onOptionsItemSelected(item);
}
#Override
protected void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
#Override
public void onComplete(#NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w("This Tag", "getInstanceId failed", task.getException());
return;
} else {
Log.d("This tag", "We need this");
}
}
});
swipeDb = FirebaseDatabase.getInstance().getReference().child("Users");
final FirebaseFirestore db = FirebaseFirestore.getInstance();
//Anonymous user login to be registered in Firebase
mAuth = FirebaseAuth.getInstance();
mCurrentUser = mAuth.getCurrentUser(); // save the UID of the user in users in Firebase without having to log in
final String UID = mCurrentUser.getUid();
DatabaseReference currentUserDb = FirebaseDatabase.getInstance().getReference().child("Users").child("UID");
currentUserDb.setValue(UID); //save the User UID to the Firebase Realtime database
// Calling to the AdMob API to add advertisements to the banner in the main view.Gotta make that dough
// Change this to big cards in the future
final AdView adView = findViewById(R.id.adView);
final AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
Screenshot to Firebase Authentication
Error I'm receiving from the logcat:
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseCrashlytics: Initializing Crashlytics 17.0.0
I/FirebaseInitProvider: FirebaseApp initialization successful
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
V/FA: onActivityCreated
W/rawesome.metim: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
V/FA: App measurement disabled via the init parameters
I/FA: App measurement initialized, version: 28000
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.superawesome.metime
D/FA: Debug-level message logging enabled
V/FA: Detected application was in foreground
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.superawesome.metime, PID: 21746
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.superawesome.metime/com.superawesome.metime.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3341)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7478)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference
at com.superawesome.metime.MainActivity.onCreate(MainActivity.java:118)
at android.app.Activity.performCreate(Activity.java:7989)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3316)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7478)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
V/FA: Connecting to remote service
D/FA: Event not sent since app measurement is disabled
com.superawesome.metime.MainActivity.onCreate(MainActivity.java:118) --> final String UID = mCurrentUser.getUid();
I've been trying to resolve this issue for over a week now with no success
Edit:
I know I can add listeners to see if the user is anonymously signed in or not. The whole problem around this is that the user is not being signed in anymore at all.
Edit2:
From logcat:
2020-05-30 12:39:53.655 23257-23297/com.superawesome.metime I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 21600
2020-05-30 12:39:53.658 23257-23297/com.superawesome.metime V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
2020-05-30 12:39:53.770 23257-23311/com.superawesome.metime I/TetheringManager: registerTetheringEventCallback:com.superawesome.metime
2020-05-30 12:39:53.818 23257-23303/com.superawesome.metime W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2020-05-30 12:39:54.025 23257-23303/com.superawesome.metime I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2020-05-30 12:39:54.076 23257-23257/com.superawesome.metime I/FirebaseCrashlytics: Initializing Crashlytics 17.0.0
2020-05-30 12:39:54.220 23257-23257/com.superawesome.metime I/FirebaseInitProvider: FirebaseApp initialization successful
2020-05-30 12:39:54.332 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2020-05-30 12:39:54.342 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2020-05-30 12:39:54.362 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2020-05-30 12:39:54.527 23257-23315/com.superawesome.metime V/FA: App measurement disabled via the init parameters
2020-05-30 12:39:55.234 23257-23315/com.superawesome.metime I/FA: App measurement initialized, version: 28000
2020-05-30 12:39:55.247 23257-23315/com.superawesome.metime I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2020-05-30 12:39:55.267 23257-23315/com.superawesome.metime I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.superawesome.metime
2020-05-30 12:39:55.274 23257-23315/com.superawesome.metime D/FA: Debug-level message logging enabled
2020-05-30 12:39:57.009 23257-23315/com.superawesome.metime V/FA: Detected application was in foreground
2020-05-30 12:39:57.995 23257-23315/com.superawesome.metime V/FA: Connecting to remote service
2020-05-30 12:40:23.846 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
2020-05-30 12:41:23.931 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
2020-05-30 12:42:54.030 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
After I install the android_alarm_manager on my project I got this error..
I/AlarmService(24713): Starting AlarmService...
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): Failed to handle method call
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.app.Activity.getExternalFilesDir(java.lang.String)' on a null object reference
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at io.flutter.plugins.imagepicker.ImagePickerPlugin.registerWith(ImagePickerPlugin.java:27)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:29)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at com.example.myapp.Application.registerWith(Application.java:18)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at io.flutter.plugins.androidalarmmanager.AlarmService.startAlarmService(AlarmService.java:65)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at io.flutter.plugins.androidalarmmanager.AndroidAlarmManagerPlugin.startService(AndroidAlarmManagerPlugin.java:75)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at io.flutter.plugins.androidalarmmanager.AndroidAlarmManagerPlugin.onMethodCall(AndroidAlarmManagerPlugin.java:52)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at android.os.MessageQueue.next(MessageQueue.java:143)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at android.os.Looper.loop(Looper.java:122)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at android.app.ActivityThread.main(ActivityThread.java:5253)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at java.lang.reflect.Method.invoke(Method.java:372)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
E/MethodChannel#plugins.flutter.io/android_alarm_manager(24713): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:708) 4.8s
🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on Mi 4i is available at: http://127.0.0.1:3860/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
E/flutter (24713): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (24713): PlatformException(error, Attempt to invoke virtual method 'java.io.File android.app.Activity.getExternalFilesDir(java.lang.String)' on a null object reference, null)
E/flutter (24713): #0 JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:149:7)
E/flutter (24713): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
E/flutter (24713): <asynchronous suspension>
E/flutter (24713): #2 AndroidAlarmManager.initialize (package:android_alarm_manager/android_alarm_manager.dart:70:10)
E/flutter (24713): <asynchronous suspension>
This is my pubspec.yaml
dependencies:
dio: "^1.0.1"
flutter:
sdk: flutter
local_auth: "^0.2.0"
shared_preferences: "^0.4.0"
http: "^0.11.3+16"
path_provider: ^0.4.1
image_picker: "^0.4.10"
multi_image_picker: "1.0.51"
datetime_picker_formfield: ^0.1.3
pull_to_refresh: ^1.1.5
connectivity: ^0.3.1
sqflite : any
location: ^1.4.1
android_alarm_manager: ^0.2.1
geolocator: '^1.7.0'
My main.dart
void main() async {
final int msgId = 0;
runApp(new LoginApp());
await AndroidAlarmManager.initialize();
await AndroidAlarmManager.periodic(
const Duration(seconds: 5), msgId, autoResendReports);
}
void autoResendReports() {
print("TEST");
final DateTime now = new DateTime.now();
final int isolateId = Isolate.current.hashCode;
print(
"[$now] Hello, world! isolate=$isolateId function='$autoResendReports'");
}
class LoginApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return new MaterialApp(
title: '',
theme: new ThemeData(
primarySwatch: Colors.green,
),
routes: routes,
);
}
}
My AndroidManifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name=".Application"
android:label="MyApp"
android:icon="#mipmap/ic_launcher2">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service
android:name="io.flutter.plugins.androidalarmmanager.AlarmService"
android:exported="false"/>
</application>
</manifest>
I still can't make the background service for flutter work. Please help.
I got stuck in similar issue for a while, so I tried to work around using the java file. So, basically what I am doing is that I have created the background logic I want using java in the android side, which is easy to do. Then I talk with that side from flutter using MethodChannel. My app is simply need to run an alarm when the app timer finish counting even if in background. I still have some issues in variable passing to the service in android side, which is minor I think, but in general the background thing worked fine for me.
I have a provider in my app
<provider android:authorities="com.myapp.android.provider" android:exported="false" android:name="com.myapp.android.provider.FileSystemProvider">
<grant-uri-permission android:pathPrefix="/"/>
</provider>
And when I call the following intent:
Intent intent = new Intent();
intent.setClassName(getPackageName(), "com.myapp.android.CameraActivity");
intent.setData(Uri.parse("content://com.myapp.android.provider/"));
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
I get exception
Caused by: java.lang.SecurityException: Permission Denial: starting
Intent { dat=content://com.myapp.android.provider/ flg=0xc3
cmp=com......../com......... (has extras) } from
ProcessRecord{44955bc0 9477:com...../u0a260} (pid=9477,
uid=10260) not exported from uid 10261
What I do wrong? I tried to specify full path to a file or different directory, but it never worked.
intent.setClassName(getPackageName(), "com.myapp.android.CameraActivity");
Most likely, this is not the actual line of code that is in your app; your real code is specifying some other app. Regardless, this component is not exported, and therefore you cannot access it from your app.
<provider android:authorities="com.myapp.android.provider"
android:exported="true"<----- change android:name="com.myapp.android.provider.FileSystemProvider">
<grant-uri-permission android:pathPrefix="/"/>
</provider>
This is my simple Camera Intent Demo in which i have only one Activity .....
package x.y;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;
public class PhotoShoot extends Activity {
final static int CAMERA_RESULT = 0;
ImageView imv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, CAMERA_RESULT);
}
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK)
{
Bundle extras = intent.getExtras();
Bitmap bmp = (Bitmap) extras.get("data");
imv = (ImageView) findViewById(R.id.ReturnedImageView);
imv.setImageBitmap(bmp);
}
}
}
And Layout main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/ReturnedImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
Manifest ...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="x.y"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".PhotoShoot"
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>
Throwing "Force close" after few seconds in Android emulator 2.2 from starting of Camera intent with following Exception ...
07-06 15:26:00.999: ERROR/AndroidRuntime(544): FATAL EXCEPTION: GLThread 11
07-06 15:26:00.999: ERROR/AndroidRuntime(544): java.lang.IllegalArgumentException: No configs match configSpec
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:760)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:916)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1246)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
any idea?
This is actually part of a bigger issue, and I'm hoping that by posting here, others who have experienced this error will read this entry. I equally hope that, if any of my conclusions are incorrect, someone comes forth with a more definitive explanation and/or solution.
The core issue is OpenGL support. Beginning at 2.2, Android supports OpenGL ES 2.0, and beginning at 4.0.3, Android emulators support OpenGL ES 2.0. Code that uses OpenGL ES 2.0 will not work on emulators before 4.0.3. [Evidently, the camera switched from ES 1.0 to 2.0 at Android 2.2]
But that's not all! None of the Android docs I've encountered mention that, in order to support Open GL ES 2.0 emulation, your box's graphic card chipset and driver must support OpenGL 2.0 as well. Therefore, if you enable GPU Emulation on the AVD and you still encounter this error, do the following:
1) Find out the specs on your graphic card and visit the chipset manufacturer's web site to determine if the chipset is OpenGL 2.0 compatible. If it isn't, you're S.O.L. and must stick to debugging through an actual Android device instead of an emulator.
2) Determine if you have the latest graphics driver for the chipset. Drivers obtained through Microsoft (if you're using Windows) typically do not support OpenGL, so you want to download the latest driver from the manufacturer.
I hope this helps.
Camera is not support in Android emulator so don't worry about it. This type of Error come in Android Emulator 2.2 and i have also Checked Android emulator 1.6 but not getting Error.
I have also checked above code in Android Device Samsung Galaxy Ace is working fine.