Example usage for android.app Instrumentation Instrumentation

List of usage examples for android.app Instrumentation Instrumentation

Introduction

In this page you can find the example usage for android.app Instrumentation Instrumentation.

Prototype

public Instrumentation() 

Source Link

Usage

From source file:Main.java

public static void sendStringSync(final String s) {
    new Thread(new Runnable() {
        @Override/*from  ww  w .j a  va 2s  .c o m*/
        public void run() {
            new Instrumentation().sendStringSync(s);
        }
    }).start();
}

From source file:Main.java

public static void sendKeyIntent(final int keycode) {
    new Thread(new Runnable() {

        @Override/*from w ww.ja va 2  s .c  o m*/
        public void run() {
            new Instrumentation().sendKeyDownUpSync(keycode);
        }
    }).start();
}

From source file:Main.java

public static void sendKeyDownUpSync(final int keyCode) {
    new Thread(new Runnable() {
        @Override//from ww  w . ja v  a  2 s  .c om
        public void run() {
            new Instrumentation().sendKeyDownUpSync(keyCode);
        }
    }).start();
}

From source file:Main.java

public static void volumeAdd() {
    new Thread(new Runnable() {
        @Override//w  w w . ja  v  a  2  s  .c o m
        public void run() {
            Instrumentation m_Instrumentation = new Instrumentation();
            m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_UP);
        }
    }).start();
}

From source file:Main.java

/**
 * this function work by permission.//from   w  ww .jav a 2 s  .  co  m
 */
public static void pressHome() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            Instrumentation m_Instrumentation = new Instrumentation();
            m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME);
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME);
        }
    }).start();

}

From source file:com.king.base.util.SystemUtils.java

/**
 * ??//from  w w  w.j  a  v  a2 s  . co m
 * @param keyCode
 */
public static void sendKeyCode(final int keyCode) {
    asyncThread(new Runnable() {
        @Override
        public void run() {
            try {
                Instrumentation inst = new Instrumentation();
                inst.sendKeyDownUpSync(keyCode);
            } catch (Exception e) {
                LogUtils.e("Exception when sendPointerSync", e);
            }
        }
    });
}

From source file:com.waz.zclient.pages.extendedcursor.emoji.EmojiKeyboardLayout.java

private void init() {
    currentEmojiSize = EmojiSize.MEDIUM;
    categoryPositions = new int[CATEGORY_COUNT];

    emojiAdapter = new EmojiAdapter(getContext());

    layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT, LinearLayoutManager.HORIZONTAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override/*  w ww  .j  a v a2s  .  c o m*/
        public int getSpanSize(int position) {
            return spaces.contains(position) ? SPAN_COUNT : 1;
        }
    });
    layoutManager.setSpanCount(SPAN_COUNT);

    recyclerView.addOnScrollListener(new EmojiScrollListener());

    tapIndicatorLayout.setShowDivider(false);
    tapIndicatorLayout.setGlyphLabels(Emojis.EMOJI_KEYBOARD_TAB_LABELS);
    tapIndicatorLayout.setTextColor(ContextCompat.getColorStateList(getContext(),
            com.waz.zclient.ui.R.color.wire__text_color_dark_selector));
    tapIndicatorLayout.setPrimaryColor(
            ContextCompat.getColor(getContext(), com.waz.zclient.ui.R.color.text__primary_dark));
    tapIndicatorLayout.setLabelHeight(getContext().getResources()
            .getDimensionPixelSize(com.waz.zclient.ui.R.dimen.sketch__emoji__keyboard__tab_label_size));
    tapIndicatorLayout.setCallback(new TabIndicatorLayout.Callback() {
        @Override
        public void onItemSelected(int pos) {
            if (pos == TAB_COUNT - 1) {
                Threading.Background().execute(new Runnable() {
                    @Override
                    public void run() {
                        Instrumentation inst = new Instrumentation();
                        inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DEL);
                    }
                });
            } else {
                tapIndicatorLayout.setSelected(pos);
                layoutManager.scrollToPositionWithOffset(getCategoryByTabPosition(pos), 0);
            }
        }
    });

    recyclerView.setAdapter(emojiAdapter);
    recyclerView.setLayoutManager(layoutManager);
    setRecyclerViewPadding(recyclerView);

    emojiAdapter.setOnEmojiClickListener(new EmojiAdapter.OnEmojiClickListener() {
        @Override
        public void onEmojiClick(String emoji, EmojiSize emojiSize) {
            if (callback != null) {
                callback.onEmojiSelected(emoji);
            }
        }
    });
}

From source file:com.umundus.service.NCallServiceOld.java

public void takeCamera() {
    new Thread(new Runnable() {
        public void run() {
            new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_DOWN);
        }//from  w  ww .j  ava 2s. c  om
    }).start();
}