intent

What is the simplest way to send message from local service to activity

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a service which is listening to the phone. When the phone goes IDLE, I want to send a message to my Activity. It looks like I have two options to accomplish this. BroadcastReceiver and binding to the Service. BroadcastReceiver looked like an easier mechanism, so I tried the following test. In my Activity: @Override protected void onStart() { super.onStart(); IntentFilter filter = new IntentFilter("MyAction"); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Yay...

Attempt to invoke virtual method in Resources res = getResources();

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to change the background color of an activity using a handler, but I am getting an error "Attempt to invoke virtual method". Here is my code public class MainActivity extends AppCompatActivity { private EditText editTextUser, editTextPass; private RelativeLayout relativeLayoutMain; private Random random = new Random(); Intent intent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); relativeLayoutMain = (RelativeLayout) findViewById(R.id

Android install apk with Intent.VIEW_ACTION not working with File provider

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My app has an auto-update feature that download an APK and when the download is finished that a Intent.VIEW_ACTION to open the app and let the user install the downloaded apk Uri uri = Uri.parse("file://" + destination); Intent install = new Intent(Intent.ACTION_VIEW); install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); install.setDataAndType(uri, manager.getMimeTypeForDownloadedFile(downloadId)); activity.startActivity(install); This works great for all the device Now with Android 24 apparently we are not allowed any more to start intents

Send HTML mail using Android intent

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have generated an HTML code(complete with tags) as a String. Now I want to send this HTML code as HTML to mail. My code is as below. Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"me@mydomain.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, "I would like to buy the following"); intent.putExtra(Intent.EXTRA_TEXT, purchaseOrder()); startActivity(Intent.createChooser(intent, "sending mail")); Where the purchaseOrder() is the method which passes me the string having

Firebase (FCM) how to get token

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: It`s my first to use FCM. I download a sample from firebase/quickstart-android and I install the FCM Quickstart.But I can`t get any token from the log even hit the LOG TOKEN button in the app. Then I try to send message with Firebase console and set to target to my app package name.I got any incoming message. I want to know can FCM be used?GCM everything is ok. Solution: Because I am not a Android developer,just a backend developer.So it takes me some time to solve it.In my opinion,there`re some bug in the sample app. Code:

How Do You Test the Android 6.0 Full-Backup Behavior?

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: TL;DR: How do you successfuly use the command-line tools (or anything else) to test the Android 6.0 backup and restore behavior, as I cannot get them to restore anything? Since I was running into problems earlier with a sample app from my book trying to get this working, I started from scratch for the purposes of this question. I created a brand-new project from the Android Studio 1.4.1 new-project wizard, accepting all relevant defaults, except I went with the "Empty Activity" template and added a 2 to the application ID and display name. I

Inner PreferenceScreen not opens with PreferenceFragmentCompat

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My inner PreferenceScreen of PreferenceFragmentCompat is not showing, or seems to ignore tapping events. I created MyPreferenceFragment that extends PreferenceFragmentCompat public class MyPreferenceFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.preferences); } } then I changed my theme at styles.xml like */ /*--> */ /*--> */ /*--> */ /*--> */ And finally create my preferences.xml file like At the build.gradle I have added

Difference between intent(out) and intent(inout)

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: According to the Fortran standard: The INTENT (OUT) attribute for a nonpointer dummy argument specifies that the dummy argument becomes undefined on invocation of the procedure However this simple code gives me 5 as output, so it seems the argument didn't become undefined at the start of the procedure (in this case a subroutine). subroutine useless(a) integer, intent(out) :: a print *,a end subroutine useless program test integer :: n=5 call useless(n) end program test What am I getting wrong? It seems that intent(inout) and intent(out) are

OnListenerCOnnected in NotificationListenerService not being called

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My app only does not work on Huawei and on other phones it does. Why??? I have that code in my MainActivity: package pl.ct8.wieprzco.wieprzwatch; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent=new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); startActivity(intent); startService(new Intent(this,NotificationGetService.class)); } } And that simple code in

Unable to get intent filters from a package

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to list all the intent filters that are present in an package. I am trying to do it using PackageManager class. I have set the flag PackageManager.GET_INTENT_FILTERS while fetching the PackageInfo object. But I dont know how to use it. I was able to get all the info related to activites and receivers using the respective flags, but dunno how to proceed for intent-filters. Any ideas how to solve this issue? 回答1: Looks like intent filters are not exposed in the API and the flag effectively does nothing: http://code.google.com/p/android