i have one activity with the same intent filters than other application. Soo when i run my app, i have to choose which action i want to be performed but i dont wanna choose this.
I always want to run my application with high priority and dont show the action chooser. Any idea for make this? thanks
I always want to run my application with high priority and dont show the action chooser. Any idea for make this?
The user can elect to do this by checking the "make this the default" checkbox at the bottom of the chooser dialog.
You, as a developer, cannot unilaterally make yourself the default.
My activity reads a tags NFC but how android have already installed other NFC app with the same intent filter i dont know any solution.
Your filter says that you want to handle all tags. If that is true, then the user will have to choose whether to make your app the default.
However, you can make a tighter filter and take priority. For example:
<activity android:name="URLHandler" android:label="#string/app_name">
<intent-filter android:label="#string/app_name">
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<data android:scheme="http"
android:host="commonsware.com"
android:path="/nfctest"
/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Here, my activity will get control if (and only if) the tag has an NDEF record that results in a URL of http://commonsware.com/nfctest. Since my filter has tighter scope than other competing applications, mine will get control without a chooser.
Related
I want to make a new input method with no actual keyboard.
It should stay active (after being enabled by user) always but not be the default keyboard. Because it will not have any visual keyboard and user will still be able to use the default keyboard as he/she selects.
I will trigger it on demand from a network command. Is this possible ?
It should be possible, because for example Android TV remote or Shield TV remote can do this.
But I couldn't find how to do it. When I create a normal input method, it only works if I select it as the default input method.
<service android:name="SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im" android:resource="#xml/method" />
</service>
This is the part from manifest file. Is it possible to make it work without selecting it as the default input method ?
As a second, additional input method …
I could not find a solution which could live together with the original leanback keyboard.
So, I found an example Leanback keyboard code , injected my rest API in it.
Now I have the leanback keyboard modified to make what I want.
I am facing some issue while developing Video capturing application.
1) When I start capturing the Video, the surface view comes in landscape mode. I tried a lot. But i failed. I also referred
http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation%28int%29 .. but no result
2) I am using release() method. but when we use that, after capturing application get closed. if I donot use this in memory card there is a video with no any capture and zero size.
Can any body explain why it is happening so?
Thanks in Advance
I spent hours on a similar problem. Anytime I released the MediaRecorder and then pressed the back button, the app would close and restart--onPause, onStop, onDestroy wouldn't fire in the Activity I was leaving, it would just be dead and then onCreate would fire in the Application.
After a lot of experimentation, I discovered the problem went away if I added
mediaRecorder = null;
immediately after calling mediaRecorder.release();
I have same issue for thread create problem and i stop first thread and my activity is below....Problem is gone.......... ...
<activity android:name=".SensorTest"
android:windowSoftInputMode="adjustPan" android:screenOrientation="sensor"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
This is only to try to answer point 1:
You probably miss the following attribute inside <activity> tag in the AndroidManifest.xml. See more here.
android:configChanges="orientation"
If you don't declare this, your app will never be notified of any device rotation.
I would like to answer only the question 1. I've stuck with this problem before, too. I found that you can use the function setOrientationHint (API 9). Call this function before you call MediaRecorder.prepare(). You can setup the orientation degree for your output video.
Hope it helps, good luck!
In a nutshell, to give you an example, I basically have an app with 3 activities:
Activity1
Activity2
StartActivity
StartActivity contains two buttons that correspond to the other two activities respectively, starting them up. If I exit the application from Activity1, when I later click on the app icon from the phone, Activity1 is restarted since Android keeps track of this. I need to have the app restart to bring me to the StartActivity, so that I can choose where to go by clicking the buttons, instead of having to click the back button to be able to end up at the StartActivity.
I'm assuming onResume and onRestart are involved, but where should they go?
Any help is greatly appreciated thank you.
You might look at the android:clearTaskOnLaunch activity attribute from the Manifest file : http://developer.android.com/guide/topics/manifest/activity-element.html
I think setting this attribute to "true" on your root activity does what you want.
I would think the solution to be destroying Activity1 and Activity2 onStop. This leaves the stack with only your StartActivity. You can call the finish method in Activity to terminate it programmatically at anytime.
Generally the way it works (from what I understand) is you use the BACK button to EXIT the activity, and the HOME button will essentially "minimize" the activity - bringing you back to whatever activity was left open.
While you should leave this functionality the same, you can override the home button to completely exit your application.
In your mainfest.xml file write like this.
<activity android:name=".StartActivity" android:label="#string/app_name"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:clearTaskOnLaunch="true" attribute automatically restart the activity.
Just add the below code into your manifest file into the activity whichever you want t open on start.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Just wondering if anyone has seen this problem and knows what might be wrong. I've constructed something of a library it has on the main page where you select A, B, C ... etc. and then it opens a page with buttons for whichever your choice is. Now the problem is when I load my app onto my phone it has one app button for the whole app and then it has one button for each A, B, C... etc .classes as in i can click on any of those and it opens directly from the phones menu. Its like the menu has been spammed and i don't think people would appreciate that. Anyone have any idea what it might be. Ive made an application that has a library type thing in it before and this problem never occurred.
Remove the MAIN and LAUNCHER intents from those other activities.
http://developer.android.com/guide/topics/intents/intents-filters.html
Activities that can initiate
applications have filters with
"android.intent.action.MAIN" specified
as the action. If they are to be
represented in the application
launcher, they also specify the
"android.intent.category.LAUNCHER"
category:
<intent-filter . . . >
<action android:name="code android.intent.action.MAIN" />
<category android:name="code android.intent.category.LAUNCHER" />
</intent-filter>
Also, work on your accept rate.
When you long press on something in Android, a context menu comes up. I want to add something to this context menu for all TextViews in the system.
For example, the system does this with Copy and Paste. I would want to add my own, and have it appear in every application.
Currently Android does not support this, you cannot override or hook functionality globally at the system level without the particular activity implementing an intent or activity that you expose. Even in the case of publishing an intent it wouldn't matter unless the application running is a consumer... and all the base system applications and obviously all applications prior to yours would not be without updating the app to consume.
Basically as it stands, this is not possible.
What exactly are you trying to accomplish with this global context menu, some sort of global "Search For" or "Send To" functionality that runs through your application?
Add intent-filter in your file android-manifest.xml:
<activity
android:name=".ProcessTextActivity"
android:label="#string/process_text_action_name">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
Get highlighted by user text in activity your app in method onCreate():
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.process_text_main);
CharSequence text = getIntent()
.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
// process the text
}
More information in the article on medium.
Thanks for user: YungBlade
Him answer on ru.stackoverflow.com
This might be a little bit hacky, but you can trap the menu key at the application/activity level, check to see if your current active view is a text entry view, and then build and display your own custom popup menu.
It is possible, it's just a little tricky.
If you create/inflate a TextView, call setFocusable(false) on it, and then set it as the active view your Activity will still receive key events.
You will have to forward all those events (trackball, touch, key) to your View tree by hand. (Inside your "onKeyDown" function you'd have to call the appropriate "onKeyDown" method for the top level View) You effectively have to trap the notion of 'focus' and dole it out to the correct view yourself.
While a little ugly, it may give you the desired results.
This would, however, only work in your own application. Previous answers are correct about it being impossible across the entire phone.
Push the Share button (tree of three dots) within selection menu. Then you should select your own app. Does't work for input field content, unfortunately.
Hmm; I don't know if you can extend built in types like in example. Ruby (my Java knowledge is not so deep enough).
However you can derive your own MyTextView from TextView. Then substitute all your TextView in layouts like this:
<TextView android:id="#+id/TextView01" />
to
<com.mydomain.mypackage.MyTextView android:id="#+id/TextView01" />
to automatically change type of all these fields.
Then you need to override all constructors
(especially TextView(Context context, AttributeSet attrs) ).
After that all layout inflaters (automatic or manual) will create this type with no fuss.
Then you can create/register context menu callbacks as you wish.