Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.joythis.android.myphonecaller;
- import android.app.Activity;
- import android.content.Intent;
- import android.content.pm.PackageManager;
- import android.net.Uri;
- import android.view.View;
- import android.view.inputmethod.InputMethodManager;
- import android.widget.Toast;
- public class AmUtil {
- Activity mA;
- public AmUtil(Activity pA){
- this.mA = pA;
- }// AmUtil
- public void feedback(String pMsg){
- Toast t = Toast.makeText(
- this.mA,
- pMsg,
- Toast.LENGTH_LONG
- );
- t.show();
- }//feedback
- public void hideSoftKeyboard(){
- //the view where the keyboard is in use is the view with the focus
- View viewWithFocus = this.mA.getCurrentFocus();
- if (viewWithFocus!=null) {
- InputMethodManager imm =
- (InputMethodManager)this.mA.getSystemService(
- Activity.INPUT_METHOD_SERVICE
- );
- imm.hideSoftInputFromWindow(
- viewWithFocus.getWindowToken(), //the token of the window that is making the request, as returned by View.getWindowToken()
- 0 //Currently may be 0 or have the HIDE_IMPLICIT_ONLY bit set.
- );
- }
- }//hideSoftKeyboard
- public boolean makePhoneCall(String pTel){
- Uri uriTel = Uri.parse("tel:"+pTel);
- Intent intentTel = new Intent(
- Intent.ACTION_CALL
- );
- if(intentTel!=null){
- intentTel.setData(uriTel);
- this.mA.startActivity(intentTel);
- return true;
- }
- return false;
- }//makePhoneCall
- String genericPermsFeedback(
- String[] pPerms
- ){
- String strFB = "";
- for (String p : pPerms){
- int iStatusP = this.mA.checkSelfPermission(p);
- boolean bG = iStatusP== PackageManager.PERMISSION_GRANTED;
- boolean bD = !bG;
- strFB+=String.format(
- "%s - %s",
- p,
- bG ? "YES" : "NO"
- );
- }//for
- return strFB;
- }//genericPermsFeedback
- }
Advertisement
Add Comment
Please, Sign In to add comment