Skip to content

Instantly share code, notes, and snippets.

@doyle-flutter
Last active February 18, 2021 06:42
Show Gist options
  • Save doyle-flutter/3b2333e58c6a55c51c6dde5e9dd70856 to your computer and use it in GitHub Desktop.
Save doyle-flutter/3b2333e58c6a55c51c6dde5e9dd70856 to your computer and use it in GitHub Desktop.
#06 백그라운드
// ... import 생략
public class MainActivity3 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
ConstraintLayout c = (ConstraintLayout) findViewById(R.id.main3);
ResultReceiver mRecevier = new ResultReceiver(new Handler()){
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
Log.d("DOY", resultData.getString("key"));
}
};
Button backButton = new Button(this.getApplicationContext());
backButton.setText("백그라운드 서비스(HTTP)");
final Intent intent = new Intent(this, MyIntentService.class);
intent.putExtra("INTENT_KEY_RECEIVER",mRecevier);
View.OnClickListener backButtonListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("DOY", "CLICK?");
startService(intent);
}
};
backButton.setOnClickListener(backButtonListener);
c.addView(backButton);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment