Note that there are some explanatory texts on larger screens.

plurals
  1. POReacting to broadcast from another process
    primarykey
    data
    text
    <p>I have class that looks like this:</p> <pre><code>package com.broadcast; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; public class BroadcastActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } public void tasterPritisnut(View target) { Intent intent = new Intent("akcija"); intent.putExtra("message", "Hello Valakar"); this.sendBroadcast(intent); } } </code></pre> <p>This is broadcast class. Manifest class is: </p> <pre><code>&lt;uses-sdk android:minSdkVersion="10" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;activity android:label="@string/app_name" android:name=".BroadcastActivity" &gt; &lt;intent-filter &gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Now I have created a new project with new class:</p> <pre><code>package com.reciever; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class Reciever4 extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String poruka = intent.getStringExtra("message"); Log.d("", poruka + " " + Thread.currentThread().getName() + " " + Thread.currentThread().getId()); } } </code></pre> <p>This is receiver class, and manifest file is like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reciever" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;receiver android:name=".Reciever4"&gt; &lt;intent-filter&gt; &lt;action android:name="akcija"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>I installed both applications, but when I send broadcast, nothing is printed in log. I have build this similar to Apress book example, but cant get it to work. What am I missing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload