intent

Android E/Parcel: Class not found when unmarshalling (only on Samsung Tab3)

匿名 (未验证) 提交于 2019-12-03 01:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been unable to resolve why this error occurs, and only on a Samsung Tab3 device, running 4.4.2? It happens when my MainActivity starts another Activity, and passes a Parcelable class in the intent like so: private void debugTest(TestParcel cfgOptions){ TestParcel cfgOptions = new TestParcel(); cfgOptions.setValue(15); //just to verify Intent intent = new Intent(MainActivity.this, TestActivity.class); intent.putExtra("cfgOptions", cfgOptions); startActivityForResult(intent, DBG_TEST); } TestActivity gets the parcelable data like so:

ACTION_MY_PACKAGE_REPLACED not received

匿名 (未验证) 提交于 2019-12-03 01:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using ACTION_MY_PACKAGE_REPLACED to receive when my app is updated or resinstalled. My problem is that the event is never triggered (I tried Eclipse and real device). This is what I do: Manifest: Code: public class MyEventReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ("android.intent.action.ACTION_MY_PACKAGE_REPLACED".equals(intent.getAction())) { //Restart services } } } This code is simple, in real one I used other events like BOOT_COMPLETED and others, and they work but

Android: Go back to previous activity

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to do something simple on android app. How is it possible to go back to a previous activity. What code do I need to go back to previous activity 回答1: Android activities are stored in the activity stack. Going back to a previous activity could mean two things. You opened the new activity from another activity with startActivityForResult . In that case you can just call the finishActivity() function from your code and it'll take you back to the previous activity. Keep track of the activity stack. Whenever you start a new activity with

Can't answer incoming call in android marshmallow 6.0

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a calling app. Here's Auto answer which works on android 4.0 and 5.0; whereas when i have an incoming call answer call button works but it doesn't work on android 6.0. I tested answer of this post but it doesn't work too : Answer Incoming Call in Android 6.0 IncomingActivity: @Override public void onClick(View v) { switch (v.getId()) { case R.id.imgaccept: { if (Build.VERSION.SDK_INT >= 21) { new Thread(new Runnable() { @Override public void run() { try { Runtime.getRuntime().exec( "input keyevent " + KeyEvent.KEYCODE

Calling startActivity() from outside of an Activity context

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have implemented a ListView in my Android application. I bind to this ListView using a custom subclass of the ArrayAdapter class. Inside the overridden ArrayAdapter.getView(...) method, I assign an OnClickListener . In the onClick method of the OnClickListener , I want to launch a new activity. I get the exception: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? How can I get the Context that the ListView (the current Activity ) is working under? 回答1:

super.onActivityResult inside adapter class? Android

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have RecyclerView with very complex item, multiple buttons/images/texts. To access each button/image I set my click Listeners inside my Adapter class. But now I am trying add function to set contact ringtone and I have a problem. I am calling the onActivityResult method like this: Intent contactIntent = new Intent(Intent.ACTION_PICK); contactIntent.setType(ContactsContract.Contacts.CONTENT_TYPE); contactIntent.putExtra("RINGTONE_POSITION", position); ((Activity) context).startActivityForResult(contactIntent, CONTACT_CHOOSER_ACTIVITY_CODE )

android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: The app is crashing when I'm trying to open a file. It works below Android Nougat, but on Android Nougat it crashes. It only crashes when I try to open a file from the SD card, not from the system partition. Some permission problem? Sample code: File file = new File ( "/storage/emulated/0/test.txt" ); Intent intent = new Intent ( Intent . ACTION_VIEW ); intent . setDataAndType ( Uri . fromFile ( file ), "text/*" ); intent . setFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ); startActivity ( intent ); // Crashes on this line Log: android

FCM - Setting badge in onMessageReceived

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have an Android application, where I'm using some method to show notification number on app icon. Now I want to set that number when notification is received. I thought that I should set the number when notification received so I set it inside onMessageReceived method. But, my problem is when my app is in background, onMessageReceived method not called, so the notification number isn't set. Following is my code. I set the number inside onMessageReceived . I already tested setBadge method and can verify that it is working. The

Start the trim video activity with an intent

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I can take a video with an intent now what are the details to create an intent to start the default video trimmer activity? And check if it present on the device? 回答1: This solution relies on a version of the AOSP Gallery2 package being installed on the device. You can do it like this: // The Intent action is not yet published as a constant in the Intent class // This one is served by the com.android.gallery3d.app.TrimVideo activity // which relies on having the Gallery2 app or a compatible derivative installed Intent

Reliably Pausing Media Playback System-Wide in Android

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The title makes this sound much simpler than it is.. I'm trying to broadcast an intent that will pause most music players. I know I can use create a KeyEvent for that will broadcast KEYCODE_MEDIA_PLAY_PAUSE with this: long eventTime = SystemClock.uptimeMillis(); Intent downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); KeyEvent downEvent = new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); ctx.sendOrderedBroadcast(downIntent, null);