android-activity

How to start Activity from Android AppWidget?

隐身守侯 提交于 2019-12-30 08:06:08
问题 Code like this works well. Intent configIntent = new Intent (context, WidgetConfigActivity.class); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pIntent = PendingIntent.getActivity(context, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteView.setOnClickPendingIntent(R.id.btn, pIntent); But I want to hide that button befor activity will appear, so I'm triing to send intent to the widget itself, perform hiding components in onReceive() method

How to start Activity from Android AppWidget?

吃可爱长大的小学妹 提交于 2019-12-30 08:06:06
问题 Code like this works well. Intent configIntent = new Intent (context, WidgetConfigActivity.class); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pIntent = PendingIntent.getActivity(context, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteView.setOnClickPendingIntent(R.id.btn, pIntent); But I want to hide that button befor activity will appear, so I'm triing to send intent to the widget itself, perform hiding components in onReceive() method

How to call recreate()?

霸气de小男生 提交于 2019-12-30 07:58:11
问题 I know this is probably extremely simple, but I just can not figure it out. I'm trying to reload/recreate an activity after an action. I know I could just use: Intent intent = getIntent(); finish(); startActivity(intent); But in reading through answers on the site I'm told to use 'recreate()' after 11 api. Any help would be appreciated, thanks! 回答1: While using the recreate method works by doing this.recreate() It was only added in API level 11. If you want to include more devices you can

Call activity method from broadcast receiver android?

狂风中的少年 提交于 2019-12-30 07:48:09
问题 In my application I am sending a port SMS to the mobile. And when the message is recieved I need to perform some task in my activity and update the UI. Manifest Declaration of receiver <receiver android:name="com.vfi.BinarySMSReceiver" > <intent-filter android:priority="10" > <action android:name="android.intent.action.DATA_SMS_RECEIVED" /> <data android:host="*" android:port="9512" android:scheme="sms" /> </intent-filter> </receiver> Receiver class public class BinarySMSReceiver extends

How to open a new Intent inside OnTouch Event?

人盡茶涼 提交于 2019-12-30 07:47:46
问题 I have a customized OnTouch Method where i check if the touch coordinates contains a rectangle.After checking the condition i want to start a new Activity.But unfortuanlely its not workin.Can someone help me out? public class custom extends SurfaceView implements SurfaceHolder.Callback{ public boolean onTouchEvent(MotionEvent event) { int touchX = (int) event.getX(); int touchY = (int) event.getY(); switch(event.getAction()){ case MotionEvent.ACTION_DOWN: System.out.println("Touching down!");

Can android application have only broadcast recevier and service without activity

爷,独闯天下 提交于 2019-12-30 07:26:30
问题 Can android application have only broadcast recevier and service without activity ? If this is possible how can i invoke broadcast receiver ? Android system automatically invokes the broadcsat receiver ? Code of Broadcastreceiver public class CheckReceiver extends BroadcastReceiver { public Context con; @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Toast.makeText(context, "Received", Toast.LENGTH_LONG).show(); // add PhoneStateListener

Start an Activity on Phone Boot in Android

假装没事ソ 提交于 2019-12-30 07:16:05
问题 I want to start my application automatically when the phone boots. I declared a BroadcastReceiver in the manifest file. <receiver android:name=".Autostart"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> I made a java file for the receiver. Autostart.java public class Autostart extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent)

Get instance of currently running activity?

浪尽此生 提交于 2019-12-30 06:33:18
问题 What i am trying to do is to dispatch the motion event to currently running activity . I have got the ComponentName of the current activity from this code ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); // get the info from the currently running task List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1); Log.d("current task :", "CURRENT Activity ::" + taskInfo.get(0).topActivity.getClassName()); ComponentName componentInfo = taskInfo.get(0)

Get instance of currently running activity?

岁酱吖の 提交于 2019-12-30 06:33:05
问题 What i am trying to do is to dispatch the motion event to currently running activity . I have got the ComponentName of the current activity from this code ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); // get the info from the currently running task List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1); Log.d("current task :", "CURRENT Activity ::" + taskInfo.get(0).topActivity.getClassName()); ComponentName componentInfo = taskInfo.get(0)

Dynamically create an activity

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 05:44:27
问题 I want to create an activity dynamically. Something like: Activity a = new Activity(); Is it possible ? Do I need a special permission ? Or is it simply not possible ? The error I get: I don't get any exception but the program stops when I try to use this instruction. 回答1: You can't instantiate an Activity if it's not in the Manifest, so you can't create one dynamically. 回答2: You can't create activity at run time so what you can u is create Layouts at the run time and change the layout