android-intent

Alarm receive don't work

爱⌒轻易说出口 提交于 2020-01-11 13:15:10
问题 I'm making an alarm receiver, but the alarm is not triggered. This is my code : Start alarm in MainActivity : private void setupAlarm(){ Intent intent = new Intent(this, com.logdata.AlarmReceiver.class); PendingIntent pIntent = PendingIntent.getService(this, 0, intent, 0); AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + 1, 1000, pIntent); Log.e("setupAlarm", "Setup alarm

How to install any Android app programmatically in Android 10

纵饮孤独 提交于 2020-01-11 13:12:09
问题 In Android 9 & 10 I face issued in install app programmatically in Android Studio using filepath apk file. Below show what I tried.. Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.setDataAndType(Uri.parse("content://"+Environment.getExternalStorageDirectory() + "/download/" + "app-release.apk"), "application/vnd.android.package-archive"); startActivity(intent); I also added required permission in manifest file . When I

onCreate() or onNewIntent() not fired when search button pressed

血红的双手。 提交于 2020-01-11 12:50:28
问题 I'm trying to implement search functionality in my app, which is very basic at the moment. When I press the search button on my Nexus, the search intent seems to not fire because neither onCreate() nor onNewIntent() gets called. I have basically copied the whole example you can find on Android developers, but it is still not working. Thanks for your help res/searchable.xml <?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android

Minimal Android widget, APPWIDGET_DELETED and APPWIDGET_DISABLED intents never being received

时光总嘲笑我的痴心妄想 提交于 2020-01-11 09:51:08
问题 I have a problem very similar to those that have been asked before, but not exactly the same. References: 1, 2, 3, 4 I have coded up a minimal Android widget, and the APPWIDGET_DELETED and APPWIDGET_DISABLED are never being received. In references 1 and 2 above, the solution presented is to implement onReceive and explicitly look for those intents. However, I inserted a log call in onReceive , and can confirm that neither of those intents are ever appearing, though APPWIDGET_UPDATE and

How to open a PDF file from res/raw Folder?

我的未来我决定 提交于 2020-01-11 09:50:43
问题 I am writing an application that opens a pdf file when you click a button. Below is my code: File pdfFile = new File( "android.resource://com.dave.pdfviewer/" + R.raw.userguide); Uri path = Uri.fromFile(pdfFile); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setDataAndType(path, "application/pdf"); startActivity(intent); However when I run it and press the button it says "The document cannot be opened because its is not a valid PDF

How to catch/listen on android web browser downloads

时间秒杀一切 提交于 2020-01-11 09:27:18
问题 I have my android application that listens for browser intents in order to catch them whenever user click on certain type of URI. More specifically, I want my app to open when user clicked on a hyperlink that point to a torrent file (i.g. http://somewhere/file.torrent). See below my intent filters from my application AndroidManifest.xml : <intent-filter > <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name=

How to get the intent that stops the service in android

一个人想着一个人 提交于 2020-01-11 09:23:26
问题 I am using stopService() to stop the service . and I want to send Extra data with the intent . how to retrieve this extra data in the service ?? 回答1: AFAIK, this Intent is not delivered to the Service in any fashion. Instead of stopService() , you can use startService() to pass your extras, and include something in there that causes your service to call stopSelf() . This will have the net effect of calling stopService() and supplying extra data at the same time. 回答2: I understand this is an

Starting Service in Android calls Applications onCreate

有些话、适合烂在心里 提交于 2020-01-11 09:13:46
问题 I am starting an android service using, startService(getApplicationContext(), MyService.class); I have correctly defined my service in AndroidManifest. Now, I am calling above code from Application create. Case 1: Calling above code from Application onCreate() I see that Application.onCreate() gets called two time. One is the desired App create and other happens when startService is called. Case 2: Calling above code from Activity in application Same behavior as case 1. Is this intended

Android Activity findviewbyid() is null

做~自己de王妃 提交于 2020-01-11 08:45:31
问题 import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.Button; public class FileExplorerActivity extends Activity { public static final String TAG="ricky"; Button button; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); button = (Button) findViewById(R.id.but);<<<------------------ if(button == null) Log.d(TAG, "FileExplorerActivity: button is null"); } public FileExplorerActivity() { Log.d(TAG,

moving from one activity to another in Android

泄露秘密 提交于 2020-01-11 07:28:06
问题 The following if my code. Please tell me what I am doing wrong? package version.nitt; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import version.nitt.R; import android.util.Log; import android.content.Intent; public class versionActivity extends Activity { private Runnable runnable; private static final String TAG="WElcome!"; /** Called when the