So finally after a lot of research I have found one way to paste the copied text and that is by using Accessibility Service.
I got the solution while searching for one exception from this stackoverflow thread.
Still for a quick view I am pasting the code over here too, If you already have copied the text and your Accessibility Service is all set then you can just use this piece of code:
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
AccessibilityNodeInfo source = event.getSource();
if (source != null && ( event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED ) ) {
try{
Thread.sleep(2000);
}catch (Exception e){
}
source.performAction(AccessibilityNodeInfo.ACTION_PASTE);
}
}
I have added Thread.sleep(2000) to give sometime for UI to load and then paste text later.