android-intent

How to keep a service alive using AlarmManager.setInexactRepeating()?

狂风中的少年 提交于 2020-08-10 08:25:06
问题 I have some existing code that spawns a service intent which does a bunch of stuff in the background. This code does work... Intent serviceIntent = new Intent(context, APMService.class); serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startService(serviceIntent); My question is: how to change this to use the AlarmManager.setInexactRepeating(...) methods? I have changed the above code to this: Intent serviceIntent = new Intent(context, APMService.class); serviceIntent.putExtra(

intent.resolveActivity returns null in API 30

99封情书 提交于 2020-08-07 21:09:52
问题 Looking at intent.resolveActivity != null but launching the intent throws an ActivityNotFound exception I wrote opening a browser or an application with Deep linking: private fun openUrl(url: String) { val intent = Intent().apply { action = Intent.ACTION_VIEW data = Uri.parse(url) // setDataAndType(Uri.parse(url), "text/html") // component = ComponentName("com.android.browser", "com.android.browser.BrowserActivity") // flags = Intent.FLAG_ACTIVITY_CLEAR_TOP + Intent.FLAG_GRANT_READ_URI

intent.resolveActivity returns null in API 30

夙愿已清 提交于 2020-08-07 21:09:48
问题 Looking at intent.resolveActivity != null but launching the intent throws an ActivityNotFound exception I wrote opening a browser or an application with Deep linking: private fun openUrl(url: String) { val intent = Intent().apply { action = Intent.ACTION_VIEW data = Uri.parse(url) // setDataAndType(Uri.parse(url), "text/html") // component = ComponentName("com.android.browser", "com.android.browser.BrowserActivity") // flags = Intent.FLAG_ACTIVITY_CLEAR_TOP + Intent.FLAG_GRANT_READ_URI

Highlighting a menu item in system settings

夙愿已清 提交于 2020-08-05 08:22:50
问题 Trying to bring up an unaswered question I found here - How to highlight android setting app menu item? As seen in this video https://www.youtube.com/watch?v=eHXBc5Mmsqs The "Power Shade" menu item is being highlighted once you enter the screen. I am trying to add the same feature to my app, guiding users to an item in the settings menu using this highlight feature. I can't seem to find any information on how to actually implement this, nor do I know if it has a specific name I could search

Open File With Intent (Android)

十年热恋 提交于 2020-08-02 05:03:00
问题 I'd like to open any file (if possible) using an Intent. I have my openFile(Uri file, String mimeType) method defined and it's called using a registered BroadcastReceiver. Here is the method: private void openFile(Uri file, String mimeType) { Intent openFile = new Intent(Intent.ACTION_VIEW); openFile.setData(file); try { context.startActivity(openFile); } catch (ActivityNotFoundException e) { Log.i(TAG, "Cannot open file."); } } I'm not currently using mimeType , I'm just trying to get this

start intent without onCreate {}

狂风中的少年 提交于 2020-07-24 03:28:04
问题 I have created a class which extends Gallery. There is no onCreate() method in super Class, and I'm unable to run my intent. This is my sample code: this.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Intent intent = new Intent(v.getContext(), ClassName.class); startActivity(intent); }} The following attempt also failed to work: Intent intent = new Intent(ThisClassName.this, ClassName

start intent without onCreate {}

帅比萌擦擦* 提交于 2020-07-24 03:26:09
问题 I have created a class which extends Gallery. There is no onCreate() method in super Class, and I'm unable to run my intent. This is my sample code: this.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Intent intent = new Intent(v.getContext(), ClassName.class); startActivity(intent); }} The following attempt also failed to work: Intent intent = new Intent(ThisClassName.this, ClassName

start intent without onCreate {}

江枫思渺然 提交于 2020-07-24 03:24:16
问题 I have created a class which extends Gallery. There is no onCreate() method in super Class, and I'm unable to run my intent. This is my sample code: this.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Intent intent = new Intent(v.getContext(), ClassName.class); startActivity(intent); }} The following attempt also failed to work: Intent intent = new Intent(ThisClassName.this, ClassName

transfer bitmap between two activities in Kotlin

三世轮回 提交于 2020-07-23 06:56:10
问题 There are some answers using java in stackoverflow but i am unable to convert it into kotlin code. I am new to kotlin. Please tell me how to transfer bitmap data from one activity to another using Intent 回答1: You need to pass the bitmap as an extra argument to the intent while starting the activity. val intent = new Intent(this, NewActivity::class.java) intent.putExtra("BitmapImage", bitmap) startActivity(intent); and retrieve it as: val bitmap = this.intent?.getParcelableExtra("BitmapImage")

transfer bitmap between two activities in Kotlin

耗尽温柔 提交于 2020-07-23 06:55:31
问题 There are some answers using java in stackoverflow but i am unable to convert it into kotlin code. I am new to kotlin. Please tell me how to transfer bitmap data from one activity to another using Intent 回答1: You need to pass the bitmap as an extra argument to the intent while starting the activity. val intent = new Intent(this, NewActivity::class.java) intent.putExtra("BitmapImage", bitmap) startActivity(intent); and retrieve it as: val bitmap = this.intent?.getParcelableExtra("BitmapImage")