android-intent,android-ndk,jni,native-code , Send broadcast Intent from native code fail

Send broadcast Intent from native code fail


Tag: android-intent,android-ndk,jni,native-code

I need to broadcast an intent from native c++ code. I am doing

system("am broadcast -a com.example.intentreceiver.receiveIntent")

The output is

Broadcasting: Intent
{ act=com.example.intentreceiver.recieveIntent }

but the broadcast is not successful.

PS-instead of am command, mkdir or mv command works perfectly.


Finally worked on other device running android 4.1.2. I was trying on android 5 lollipop and did not work.

update: it was a false positive. Finally after examining logs, I made the following changes in manifest and it worked.



Implementing a File Picker in Android and replicating the selected file at another location

I'm trying to implement a File Picker in my Android project. What I've been able to do so far is : Intent chooseFile; Intent intent; chooseFile = new Intent(Intent.ACTION_GET_CONTENT); chooseFile.setType("*/*"); intent = Intent.createChooser(chooseFile, "Choose a file"); startActivityForResult(intent, PICKFILE_RESULT_CODE); And then in my onActivityResult() switch(requestCode){ case PICKFILE_RESULT_CODE: if(resultCode==-1){ Uri uri =...

Android Intent and Intent filter

I have a problem here with my code. I want to pass from an activity to another from a button. Here is my code: MainActivity.class ImageView imgsettings; inside onCreate() imgsettings = (ImageView) findViewById(; imgsettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent("android.intent.action.SETTINGS")); } }); AndroidManifest <activity android:name=".AppSettings" android:label="@string/title_activity_app_settings"...

Is it secure to pass PIN via bundle/extras in Android?

I need to ask the user to enter his app pin and confirm that pin by entering it again. I am not going to save that pin on the device and will sent it on server as soon as I get it. While implementing confirmation screen, this question came into...

Unable to Register Android App with GCM : Not allowed to start service Intent

Building An App using the Android Studio. There is some issue in the App configuration that throws a java.lang.SecurityException. The project is stored in The AndroidManifest.xml <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" /> <uses-permission android:name="android.permission.GET_ACCOUNTS"/> <uses-permission...

double* android ndk crash

I'm facing a peculiar problem with the android ndk. I'm trying to read a previously stored set of bytes in an unsigned char* readBytes (previous allocated and read from file). The data needs to be interpreted as double. unsigned char* svDataOffset=(unsigned char*)(readBytes+byteCounter); unsigned char* chars=(unsigned char*)(svDataOffset+2); //offset of 2 is...

Crop Image Located in Internal Storage

I am having trouble using the crop intent in Android. I am storing images in the internal storage allocation for my app and I want to be able to crop them and then set them as the wallpaper. I can get it to work with an image stored in external...

Multiple notification handling

I'm having trouble in figuring out the Intent, PendingIntent Filters and Flags for notifications. Notification are working and are getting generated as they should, but the problem is only the last notification created keeps the Bundle Data. I want all notification to keep the Bundle Data of each notification in...

how to pass data intent in different textview in android

I have 3 activities layouts. In the first layout I want the user to input a number that had displayed (almost same with captcha) and in the second layout too. Next i want to pass the result to the last layout. Here is my code. firstlayout: EditText periksaAnsTxt = (EditText)...

Android Notification: Intent.FLAG_ACTIVITY_NEW_TASK required?

In the document of the Notification class I see this: public PendingIntent contentIntent The intent to execute when the expanded status entry is clicked. If this is an activity, it must include the FLAG_ACTIVITY_NEW_TASK flag, which requires that you take care of task management as described in the Tasks and...

Bluetooth pairing - how to show the simple Cancel/Pair dialog?

I have prepared a simple test project for this question at GitHub. I am trying to create an Android app, which would scan a QR code from a computer screen and then use the data (MAC address and PIN or hash) for easy pairing (bonding) with a Bluetooth device. Similar...

Simplest way to use / create a PendingIntent

Maybe there's something really simple that I don't see. I'm trying to call a method from some API, and this method asks for a PendingIntent to send me asynchronously some value. I've read the doc and examples for half an hour, and can't wrap my head around a simple way...

Android armeabi devices with API level 15+

I'm developing an app for API level 15+ that has some jni code and i'm wondering if there are devices with armeabi ABI (ARMv5) and API level 15+ Can i include only armeabi-v7a and x86 libraries and skip the old armeabi?...

How are android intents handled at runtime?

I understand that intents are used to start new activities and services and can contain information about these - certain UI options, etc. They can be emitted by some activities or apps to signal that others should begin or end, or that some change should occur. I don't understand how...

SigninActivity is not an enclosing class

I'm trying to change the activity on "onPostExecute" but it doesn't seem to work even though it works on other activities. Here's my code: public class SigninActivity extends AsyncTask<String,Void,String>{ private TextView statusField,roleField; private Context context; private int byGetOrPost = 0; public SigninActivity(Context context,TextView statusField,TextView roleField,int flag) { this.context = context;...

how to fetch all column Values based on Email

I want to fetch my all the column from table tblReg, It has column Registration,Name,Password,Email and Contact out which Email is checked while registration ,it is unique column.. value exist only once in table of one Email. I am having login by matching Email with password and passing value of...

take screenshot from layout and share via android

I use below code to take screen shot from my layout and share it via android intent but the captured screen shot in the selected app is not showing any thing. @Override public void onClick(View view) { shareBitmap(this,takeScreenshot()); } public Bitmap takeScreenshot() { try{ View rootView = getWindow().getDecorView().findViewById(; rootView.setDrawingCacheEnabled(true); return...

Is it possible to share multiple text by using share intent?

I intend to share 6 text information, however it always shows the last information only, i.e. share.putExtra(Intent.EXTRA_TEXT, Contact); I also tried to use a string array to store all 6 information, i.e: share.putExtra(Intent.EXTRA_TEXT, stringArray); However, it still doesn't work. Can anyone help ? Thank you. My code: public class SingleJobActivity...

Android Receive SMS Intent: Get Message Id or Thread Id

I have register a Broadcast listener to receive the android.provider.Telephony.SMS_DELIVER Intent action. I seem to be able to get the body, and sender phone number of this new message. However I am not able to get the Message Id or Thread Id of this new message. The only way I...

Android NDK error bash: ../../build/intermediates/classes/debug/: Is a director

ubuntu kylin system NDK version r10e SDK version android-22 Details command: javah -d jni -classpath /home/king/ide/android-sdk-linux/platforms/android-22/android.jar;../../build/intermediates/classes/debug/ com.lengking.ndk.MainActivity error :bash: ../../build/intermediates/classes/debug/: Is a director I did not find the answer on the Web

Getting arguments from a bundle

I'm trying to pass arguments from my Activity to a Fragment and I'm using this code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); String message = getIntent().getStringExtra(Intent.EXTRA_TEXT); DetailActivityFragment fragment = new DetailActivityFragment(); Bundle bundle = new Bundle(); bundle.putString(INTENT_EXTRA, message); fragment.setArguments(bundle); } I'm getting the value of the message variable...

prevent asynctask to run after intent and starting the activity

I have tried to prevent an asynctask to run after changing the activity through intent but even after calling finnish() the activity is still creating. I am trying to see if a user got filled the username/password or not in my application, if they are not filled it should be...

Passing Number[] array through Intent

i am struggling on passing an array from one activity to another. In my MainActivity i build an array similar to this: Number[] s1 = {1, 8, 5, 2, 7, 4}; The reason i need it in that format, is to graph those points using androidplot in the other activity....

Android : AlarmManager is not wroking properly. It is not able to set the alarm

Here is my code Code to set Alarm. This is the code I tried, but unfortunately it won't set the Alarm at all. Please help me with this. The AlarmManager is the only way I know to set alarm. Could anyone tell me if ther is some other way. I...

How to mock a Android NFC Tag object for unit testing

I'm currently working on an Android project which needs NFC integration. Now I want to write some (j)unit tests to see if the application can receive NFC intents (specifically ACTION_TECH_DISCOVERED) and put the given tag (in NfcAdapter.EXTRA_TAG) on a bus system. However to my surprise I cannot create a Tag...

OpenGL framebuffer android without GL_OES_packed_depth_stencil (on Nexus 7 2012)

How do I init the framebuffer with depth and stencil on a device which does not support GL_OES_packed_depth_stencil (In my case a Nexus 7 2012)? This does not work: glGenRenderbuffers(1, &depthStencil); glBindRenderbuffer(GL_RENDERBUFFER, depthStencil); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthStencil); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthStencil); GLenum status =...

How to set an image on imageView from the gallery and image taken by camera in Android?

In my app I want to set an image on a Image View from gallery and I want to set an image which is taken by the camera.I have tried this code ,but when I load image from gallery ,it is working.But when I try to take a picture to...

Launching email client programatically in android and passing email address to client

In my app I have a contacts page that when the user clicks on the contacts name a drop down appears with the email and phone number of the contact. I am launching the email client in the onClick method of the text view that contains the email address, using...

Cannot resolve constructor Intent

Im trying to add a tabhost to my application but i cant figure why this error 'cannot resolve constructor intent' is showing, here's my activity code: public class SixthFragment extends Fragment { public static final String TAG = "sixth"; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)...

Sync Adapter not calling onCreate

Do we need to start the Sync Adapter service or framework starts implicitly? I have put a log on Constructor, onCreate, onDestroy of Sync Adapter service and when I start the app, I don't see the logs in the logcat. But when I do on activity onCreate Intent serviceIntent =...

Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference

Unable to pass data from one fragment to another using intent. Logic is fine .Please check the last parts of main activity where I have sent strings to other activity using putExtra. Here is the : public class MainActivity extends Activity implements View.OnClickListener { EditText ed1,ed2,ed3,ed4,ed5,ed6; Button bt1; TextView...

How to make android NDK work in windows?

I have downloaded android-ndk-r10e & I have also setted path in environment variable as well as NDK path for eclipse. I was able to build and run HelloJni sample app from eclipse, but when I use console to build it says 'ndk' is not recognized as an internal or external...

Error for cv::FileStorage in JNI

I am getting errors while compiling my native.cpp file in Eclipse ADT/NDK. While compiling the following lines of code FileStorage storage(nativepath, FileStorage::WRITE); storage << "img" << mat; storage.release(); The errors are D:/androidworkspace/Augmented-Reality//obj/local/arm64-v8a/objs/ndksetup/native.o: In function Java_com_shahrukh_AugmentedReality_CAMShiftDetection_savemat(_JNIEnv*, _jobject*, long long, _jstring*)': D:\androidworkspace\Augmented-Reality/jni/native.cpp:14: undefined reference...

Android Implicit Intent for Viewing a Video File

In my Android app, I have a button that when clicked, launches the external application of my choice to play a video (I gather that this is called an "implicit intent"). Here is the relevant Java code from my onCreate method. Button button = (Button) findViewById(; button.setOnClickListener ( new Button.OnClickListener()...

Return a String from a Thread Android Java

I am using a Thread to perform an HttpURLConnection and get data from my database. The code below represents what I would like to accomplish but I get an error on the line str_Data = "John Doe"; Error: Variable 'str_Data' is accessed from within inner class public void onCreate(Bundle savedInstanceState){...

Dealing with Fragment and listView and JSON

I am trying to make an application with MenuDrawer that contains 4 fragments. This is how my application show do. When it starts, it should retrieve data from a website. The retrieved data should be in a listview in the first fragment. The second fragment should contain a webview to...

Android parentActivity not getting recreated after startActivityForResult returns

I have a MainActivity and inside it, I am loading a fragment A. From FragmentA , I am calling google placepicker activity using startActivityforResult as follows. PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); Intent intent =; getActivity().startActivityForResult(intent,PLACE_PICKER_REQUEST); But when I select place, onActivityResult(either in FragmentA or MainActivity) is not getting called....

Android: Using an intent to start any activity

I have been working on an application that has a bunch of formulas in it. The user can select which formula they need to use, input the numbers/variables, and the program will return whatever answer they are looking for. Each formula has its own class and since there are so...

Sending Intent from BroadcastReceiver class to currently running activity

I have a class which extends BroadcastReceiver. On receiving a SMS, I would like to pass information to my main activity class to display the text in a box (Append, if already text is present). public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent...

How to resolve Out of Memory Error on Bitmap in Android?

I want to set an image in image view,I am retrieving the image path in my first activity and I am passing it via intent as a String to second activity.In the second activity I set the path to an image view,It is working properly , and I need to...

Start and stop recording from a button in a notification

I have a notification with a "Record" button. The desired functionality is that the app will start recording with the device's microphone when the button is clicked, and stop when it is clicked again. It should behave similarly to a Play/Pause button of a music app. There are also other...

Pasing data through app after install without launching

Refering to this post I need to ask something else. I have an application "A" which download and install another app "B". I want B to "transfer" data to A and then A will use this data to do work. I know that we can transfer data with intent. After...

How to upscale and render remote(RGB565) frame buffer on Android native?

I have ported remote frame buffer receive C code on Android 4.2.2 which receives frame buffer from host in RGB565 format. Able to render the received framebuffer following the standard android example frameworks/native/services/surfaceflinger/tests/resize/resize.cpp. Following is the code snippet used sp<Surface> surface = client->createSurface(String8("resize"), 800, 480, PIXEL_FORMAT_RGB_565, 0); SurfaceComposerClient::openGlobalTransaction(); surface->setLayer(100000); SurfaceComposerClient::closeGlobalTransaction();...

android - No Activity found to handle intent action.VIEW

I got an exception in my android app: 06-18 17:57:39.816 6333-6333/com.appsrox.instachat E/InputEventReceiver﹕ Exception dispatching input event. 06-18 17:57:39.816 6333-6333/com.appsrox.instachat E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback 06-18 17:57:39.816 6333-6333/com.appsrox.instachat E/MessageQueue-JNI﹕ android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=href (has extras) } at...

Passing HashMap using intent returns null, why?

I'm trying to pass a hashmap from one activity to another using intent. I already found a solution which should work. I implemented Serializable in class Player. private HashMap<Integer, Player> players = new HashMap<Integer, Player>(); players.put(1, new Player("name")); Intent intent = new Intent(this, GameActivity.class); intent.putExtra("players", players); startActivity(intent); But when I...

Android compiles but crashes

i am trying to develop my first app. It compiles and installs but crashes when I open it. Here is the Code public class MainActivity extends ActionBarActivity implements OnItemClickListener { private ListView listview; private DrawerLayout drawerlayout; private ActionBarDrawerToggle drawerListener; private LinearLayout menu; private myAdapter myadapter; @Override protected void onCreate(Bundle savedInstanceState)...

How to open “zxing Barcode” scanning screen in a small window?

"zxing Barcode" scanner is successfully working in my App I want to open the scanning screen (i.e., Intent), on same Activity in the center in a small window How can I get this type of Interface ?

Automatically copy .so files from NDK library project?

Using Android Studio with Gradle 1.2.3. I have an NDK library project A that produces a number of .so files in its own libs folder. Though, I cannot see the reference to this folder anywhere in the build.gradle file. When I reference library A from my app MyApp I...

Clear back stack but keep transition animations

My application scenario looks like this : MainActivity > TaskActivity > TaskActivity > TaskActivity > ... > MainActivity Each TaskActivity launches next one depending on the user content is able to go back to MainActivity Previous activities do not need to be kept in back stack. Actually I want them...

Native Code: cannot use typeid with -fno-rtti

I'm trying to build native code on android because I want to use VTK for my android tablet. However, I am facing some issues when it comes to building one of the vtk examples. I know this problem has been covered here for an objective c issue but I guess...

Open Map Activity from GCM Push Notification

I am trying to open a specific activity called 'MapActivity' where I want to load my current position on a map and get nearby places. I got that working and also got GCM working to send push notifications to my device (Android 4.3). The only problem left is opening that...