Merge pull request #3034 from jason-simmons/gradle_flx_refresh

Support "flutter refresh" in the Gradle-based sample project
This commit is contained in:
Jason Simmons
2016-04-01 12:39:04 -07:00
parent f7e6100b08
commit 379c563b62
3 changed files with 33 additions and 5 deletions

View File

@@ -6,6 +6,8 @@ package com.example.flutter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
@@ -76,6 +78,20 @@ public class ExampleActivity extends Activity {
flutterView.onResume();
}
@Override
protected void onNewIntent(Intent intent) {
// Reload the Flutter Dart code when the activity receives an intent
// from the "flutter refresh" command.
// This feature should only be enabled during development. Use the
// debuggable flag as an indicator that we are in development mode.
if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
if (Intent.ACTION_RUN.equals(intent.getAction())) {
flutterView.runFromBundle(intent.getDataString(),
intent.getStringExtra("snapshot"));
}
}
}
private void sendGetRandom() {
JSONObject message = new JSONObject();
try {