+

Search Tips   |   Advanced Search

Receiving data from the web view in a Java page

To receive data from the calling web view, follow these instructions.

The page must be implemented as an Activity object or extend an Activity. As with any other activity, we must declare this activity in the AndroidManifest.xml file.

To receive data from the calling web view, use the Intent object defined on the native Activity. The MobileFirst client framework makes the data available to the Activity in a Bundle.


Example

Sending data from web view to the native Activity:

Receiving the data in the native Activity:

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  //Read int value, default = 0
  Integer gameLevel = getIntent().getIntExtra("gameLevel", 0);
  //Read String value   String playerName = getIntent().getStringExtra("playerName");
  //Read boolean value, default = false
  Boolean isKeyboardEnable = getIntent().getBooleanExtra("isKeyboardEnable", false);
}


Parent topic: Web and native code in iPhone, iPad, and Android

Related information:

http://developer.android.com/reference/android/content/Intent.html
http://developer.android.com/reference/android/app/Activity.html
http://developer.android.com/reference/android/os/Bundle.html