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.
Related
I have a problem when I rotate my device, my activity is re-executed and the values change.For example, suppose that you have an activity with a button, when this button is clicked, it will show the increased value in a text view (a counter). And when you put your device in landscape mode, the activity will run again, and you will see (again) the value increased. My question is, is there a way to not run the activity again when you rotate the device ?
Please read this. You will see that there are two solutions for handling configuration changes:
You can declare that you are handling the change on your own by updating activity in the manifest. This way your activity will not be restarted and onConfigurationChanged() will be called:
<activity ...
android:configChanges="orientation|screenSize"
...>
You can pass your data objects to the new activity via onSaveInstanceState() function. Passing large objects can slow down the app. It is better you separate data from the view for example by using ViewModels, which are retained in these kind of changes.
First way may seem easy, but it is not recommended as you can see in the link provided at the beginning:
Caution: Handling the configuration change yourself can make it much
more difficult to use alternative resources, because the system does
not automatically apply them for you. This technique should be
considered a last resort when you must avoid restarts due to a
configuration change and is not recommended for most applications.
Add android:configChanges in your activity
<activity name= ".YourActivity" android:configChanges="orientation|screenSize"/>
In the manifest file add android:configChanges = "orientation|screenSize"
to the activity tag.
For ex:
<activity
android:name=".dummyActivity"
android:configChanges = "orientation|screenSize"/>
If you want to handle orientation changes manually you can do so by overriding the onConfigurationChanged() method in Activity.
For more info refer Handling Configuration Changes
add this to the manifest
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
If configChanges contains uiMode, remove it. If you don't want to uninstall uiMode, you can update these libraries.
androidx.appcompat:appcompat:1.2.0-rc01
androidx.core:core:1.3.2
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!
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.
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.