toast

Android双卡打电话和发短信

自闭症网瘾萝莉.ら 提交于 2019-12-03 04:19:45
一、打电话   首先需要申请电话信息权限,AndroidManifest.xml权限配置如下所示。 1 <!-- 打电话的权限 --> 2 <uses-permission android:name="android.permission.CALL_PHONE"/> 3 <uses-permission android:name="android.permission.READ_PHONE_STATE"/>   Android5.1及以前版本只需要在AndroidManifest.xml中配置完权限后就可以进行打电话,打电话方式如下: 1 Intent intent = new Intent(Intent.ACTION_CALL);//android.intent.action.CALL 2 //2). 携带数据 3 String number = et_main_number.getText().toString(); 4 intent.setData(Uri.parse("tel:"+number)); 5 //3). startActivity(intent) 6 startActivity(intent);   对于Android5.1以后的版本,除了AndroidManifest.xml权限配置以外,还需要通过用户允许获取权限,代码如下所示: 1 //检测用户是否同意权限

which context to use in service?

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to call method in some other class which need Context as input parameter but i have 3 possibility in service: - getApplicationContext - getBaseContext - getApplication Which one to use in ScreenService which extends Service what is the main different. I read some times ago that is not good to use getApplicationContext. Is that true? 回答1: Application context is attached to the application's life-cycle and will always be same throughout the life of application. So if you are using Toast, you can use application context or even activity

Toast not showing up in UnCaughtExceptionHandler

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using this code to handle any uncaught exceptions which might cause my application to crash. public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler { private final Context myContext; public ExceptionHandler(Context context) { myContext = context; } public void uncaughtException(Thread thread, Throwable exception) { Toast.makeText(myContext, "The application has crashed, and a report is sent to the admin", Toast.LENGTH_SHORT).show(); StringWriter stackTrace = new StringWriter(); exception.printStackTrace(new

How to disable Toast Messages generated in Screen Pinning?

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i'm developing lockscreen application, and i want to disable home button, my app is - Device Owner and Device Administrator now i'm usnig screen pinning for disable home button. but if i started activity each time i get msg "Screen pinned" and on close "Screen Unpinned" and if click on home then, "Unpinning isn't allowed by your organisation" i want to remove all those toast messages. please suggest me solution for that or if you have any other better solution to disable home button then please help me..! 回答1: Assuming you used the ADB to

Android kill background application from our application programmatically

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My requirement forces me to kill another apps from my developed application. Details: My requirement is how to kill all background running application from currently developing application programmatically. I refer this post but I am not able to understand how to implement this. Actually I want to develop somthing like ShutApp . In this, application force-closes app other background running application. I am stuck into developing this feature. Any hint/suggestion would be helpful. Thanks in advance. EDIT <uses-permission android:name=

Checking toast message in android espresso

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Would anyone know how to test for the appearance of a Toast message in android espresso? In robotium its easy & I used but started working in espresso but dont getting the exact command. 回答1: This slightly long statement works for me: import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.RootMatchers.withDecorView; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withText;

Cannot resolve maketext() method of Toast

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting error while creating a Toast Toast toast = Toast.makeText(this, text, duration); I am getting cannot resolve makeText() method of Toast . I am getting this error java: no suitable method found for makeText(idtech.ESDN.ShapeData,java.lang.CharSequence,int) method android.widget.Toast.makeText(android.content.Context,int,int) is not applicable (actual argument idtech.ESDN.ShapeData cannot be converted to android.content.Context by method invocation conversion) method android.widget.Toast.makeText(android.content.Context,java.lang

how to use twitter api in my android application to implement follow button only

匿名 (未验证) 提交于 2019-12-03 02:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Hi Guys I have gone through various links over twitter implementation. I'm successfully able to tweet and get my followers from twitter. Now the next task is to follow us functionality of twitter in my app. Can anyone tell me the simple way to implement it. I'm stuck from last one day. Not able to get rid of this. Please dont take this question for voting down and various things. It would be great if someone can provide me any sample code url and straight way answer to it. Here's the links I have gone through: https://dev.twitter

onTaskRemoved of a Android Service is never being called ! Why?

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am stuck with a issue from last 2 days, I want to hit a api and show user a Toast when user swipe off the app from Background Task, I found that from service it is possible as onTaskRemoved is called when app is removed from background. Code : MyService.java public class MyService extends Service { private static final String TAG = MyService.class.getSimpleName(); Handler mHandler; @Override public void onCreate() { super.onCreate(); mHandler = new Handler(); } @Nullable @Override public IBinder onBind(Intent intent) { return null; }

onActivityResult returns with data = null

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Ok so this here is the intent I am sending Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name startActivityForResult(intent, REQUEST_CODE); And then in the onActivityResult I am doing this: protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i("Intent name:",data.toString()); if (requestCode == REQUEST_CODE){ if (resultCode == Activity