This is my first time using the stackoverflow I am creating a chat program but only coding the broadcast receiver and receiving message notification left. I created an exampleapp for my intent but it only works when app is open. How can i simply create a broadcast receiver?
I am not getting error
My MainActivity:
package com.example.backgroundservice;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.widget.Toast;
import com.example.backgroundservice.R;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startService(new Intent(this, BackgroundService.class));
Toast.makeText(this, "Intent Başladı!", Toast.LENGTH_LONG).show();
}
}
(I did not added my other codes because i am getting error and i can not solve because i am coding on android)