codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

Override default application to handle intent


By : , Category : android

I do not know the exact answer to your question, but there is a bit more complicated decision. You can get a list of browsers, that installed on smartphone:

PackageManager manager = getPackageManager();
List<ResolveInfo> info = manager.queryIntentActivities(myIntent,PackageManager.MATCH_DEFAULT_ONLY);

And then create a choose dialog manually.

P.S. Maybe there is a more simple solution ...

ReLated :

Try this your manifest..

    <activity
        android:name="com.app1.Aboutus"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

      <activity android:name="com.app1.ABOUT"/>         

      <activity android:name="com.app1.PREFS"/>        

In java

case R.id.aboutus:
    Intent i = new Intent(Aboutus.this, ABOUT.class);
    startActivity(i);
    break;

case R.id.preferences:
    Intent s = new Intent(Aboutus.this, PREFS.class);
    startActivity(s);

While your activity (either "view" or "select an item") is in the foreground, you can use the foreground dispatch to detect new tags. See the NfcAdapter's enableForegroundDispatch() method. An activity that is registered with the foreground dispatch will take precedence over intent filter's in the app manifests.

Here is a possible solution:

Override below method in your activity.

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);           
}

After overriding above method, now you can easily listen HOME Key press in your activity using onKeyDown() method.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {     

    if(keyCode == KeyEvent.KEYCODE_HOME)
    {
       //The Code Want to Perform. 
    }
});

Reference: http://nisha113a5.blogspot.com/

You seem to have a spelling mistake in your URL:

goToUrl("htpp://stackoverflow.com/");

should be:

goToUrl("http://stackoverflow.com/");

Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .