toast

how to set an onclick listener for an imagebutton in an alertdialog

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a layout with an ImageButton that is inflated in an AlertDialog, where/how should I set an onClick listener? Here's the code I tried using: ImageButton ib = (ImageButton) findViewById(R.id.searchbutton); ib.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(TravelBite.this, "test", Toast.LENGTH_SHORT).show(); } }); 回答1: Try to put like this in ur code e.g:-if your alertdialog's object is ad,then ImageButton ib = (ImageButton) ad.findViewById(R.id.searchbutton); ib.setOnClickListener

Read Google Hangouts messages using Android

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have an app that reads out GTalk messages using TTS. Google Hangouts replaced GTalk so now I need to integrate with Hangouts. I finally got a content observer working which gets called when Hangouts gets a message. getContentResolver (). registerContentObserver ( Uri . withAppendedPath ( Uri . parse ( "content://com.google.android.apps.babel.content.EsProvider/" ), "messages" ), true , observer ); When the observer is called public void onChange ( final boolean selfChange ) { if ( paused ) { Toast . makeText ( application ,

SMS Manager send mutlipart message when there is less than 160 characters

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I write a app which use SMS Manager. I use method sendTextMessage() but it isn't work. Now I am using sendMutlipartTextMessage() and it's work. But it's send multipart message when it is about 60 characters. This is normal? Everywhere I read than should be 160 characters. This is important to me because I must pay more. 回答1: The message character limit depends on the character bit-size of the alphabet you're using. For the standard GSM 7-bit alphabet, the character limit is 160. For an 8-bit alphabet, it is 140, and for a 16-bit alphabet,

Android check null or empty string in Android

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my trying AsyncTask I get email address from my server. In onPostExecute() I have to check is email address empty or null . I used following code to check it: if (userEmail != null && !userEmail.isEmpty()) { Toast.makeText(getActivity(), userEmail, Toast.LENGTH_LONG).show(); UserEmailLabel.setText(userEmail); } But in my Toast I see null is printed. My full code: private class LoadPersonalData extends AsyncTask<String, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); } protected Void doInBackground(String...

Toast equivalent on Xamarin Forms

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Is there any way using Xamarin Forms (not android or ios specific) to have a popup, like Android does with toast, that needs no user interaction and goes away after a period of time? From searching around all I'm seeing are alerts that need user clicks to go away. 回答1: There is a simple solution for this. By using the DependencyService you can easily get the Toast-Like approach in both Android and iOS. Create an interface in your common package. public interface IMessage { void LongAlert ( string message ); void ShortAlert ( string

Open app permission settings

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Regarding granular permissions on Android M. In case the user denies twice the request for a permission, Or that the user mark the "Never ask again". How can I open/link directly to the app permissions settings? 回答1: Let's assume in AndroidManifest.xml you have: <uses-permission android:name="android.permission.WRITE_CALENDAR"/> <uses-permission android:name="android.permission.WRITE_CONTACTS"/> <!-- ETC. --> Then, as in the below sample activity, we can check for existing/granted permissions and then send the user to app settings if we're

Check if marker is inside circle radius

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to know if a given marker is inside a circle radius. In javascript, i can do something like: google.maps.geometry.spherical.computeDistanceBetween(latLngCircleCenter, latLngPoint); But in android, using maps-v2, i'm stucked. 回答1: After a lot of research, i found a very simple solution: float[] distance = new float[2]; Location.distanceBetween( marker.getPosition().latitude, marker.getPosition().longitude, circle.getCenter().latitude, circle.getCenter().longitude, distance); if( distance[0] > circle.getRadius() ){ Toast.makeText

How to open camera ONLY in a fragment

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Following code opens camera but covers complete screen, and after capturing image it returns to the fragment No signs of clicked image. ( image is safely saved in gallery. I want to open camera ONLY IN FRAGMENT part. I have copied the code from here . I just removed 'viewHolder' (4rth line of try()) as I don't know what it was doing. and declared URI variable at top in my code. I also have tried other answers like this but they are complicated as I am developing on API 19. //my declared variables private static final int CAPTURE_IMAGE

Android: When I try to install my signed app, it says “App not installed”

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I try to install a signed apk file, the application installer says "App not installed". It happens to every app that I have made. Even if I create a brand new keystore, or if I set the build mode to debug. Although it does work if I install it through the Android Studio. But if I need to share it with my friends I can't. I tried to look for a question that can appeal my situation on this site, but I haven't found any. My application is working and (supposedly) signed. I can't find any reason for it not to work. For example, this is the

Attempt to invoke virtual method &#039;void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)&#039; on a null object reference

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The problem is as follows. I have a login activity (in Android Studio) which worked fine a few days before. I don't remember changing anything but when I run this one the previous time the app closed right after I clicked the login button. The last thing indicated was the toast about pre-execution of AsyncTask. And I can't understand why there could be a NullPointerException. I have almost the same code for my signup activity and it works fine. Here is the log: EDIT 1 I had my eyes opened, the problem is not with LoginActivity, but with