Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4617634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:09:07+00:00 2026-05-22T02:09:07+00:00

In many articles, tutorials, docs, have read so far, that we call startService() or

  • 0

In many articles, tutorials, docs, have read so far, that we call startService() or bindService(), both starts the service. We can call both also, but that’s a different story. I am unable to bindService without startService().

    private void bindTunManagerService(int flags) {
    TunnelManagerService.setParentActivity(this);
    Intent bindIntent = new Intent(this, TunnelManagerService.class);
    startService(bindIntent);
    tunManagerServiceStarted = bindService(bindIntent, tunConnection, BIND_AUTO_CREATE);

    Log.d(TAG, "tunManagerServiceStarted  : " + tunManagerServiceStarted + ", ** tunManagerService = " + tunManagerService );

In the above code, if I comment startService(), bindService returns false and tunManagerService = null, even onServiceConnected is not fired up and I get “Unable to sart service intent {…} not found” message. After adding startService, service’s onCreate, onStart, onServiceConnected are called and is successfully bounded.

In practical usage, is it necesary to first startServie & then only we can bindService(). It implies that without startSErvice, we can’t bindService !! If this statement is wrong, why I can’t bindService without starting it ?

Any ideas ????

CODE ADDED

ServiceConnection :

    private ServiceConnection tunConnection = new ServiceConnection() {

    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
        Log.d(TAG,"onServiceConnected" );
        tunManagerService = ITunnelManagerService.Stub.asInterface(service);
        doConnect();
    }

    @Override
    public void onServiceDisconnected(ComponentName name) {
        Log.d(TAG,"onServiceDisconnected" );
        tunManagerService = null;
    }

};

Service :

public class TunnelManagerService extends Service {
@Override
public IBinder onBind(Intent arg0) {
    return binder;
}

@Override
public void onCreate() {
    super.onCreate();
    Log.d(TAG, "TunnelManagerService: onCreate");
    setCreatedPreference(true);
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i(TAG, "Received start id " + startId + ": " + intent);
    return START_STICKY;
}

@Override
public void onDestroy() {
    super.onDestroy();
    setCreatedPreference(false);
    hideNotifConnected();
    Log.d(TAG, "TunnelManagerService: onDestroy");
}

private final ITunnelManagerService.Stub binder = new ITunnelManagerService.Stub() {
  // contains all methods
}

...............
.............

}

Manifest :

        <activity android:name=".StartUltimate" android:label="@string/app_name" 
         android:launchMode="singleTask" android:windowSoftInputMode="stateHidden|adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service android:name="orange.android.vpn.utilities.TunnelManagerService" android:enabled="true"></service>

I use 2.3.3 SDK i.e. API 10. My activity from which I am calling is in “orange.android.vpn” and the service related files are in “orange.android.vpn.utilities” packages respectively.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:09:08+00:00Added an answer on May 22, 2026 at 2:09 am

    I found the solution, so am sharing with all of you.

    There are 2 types of Services : One where you start and stop. This can be started and stopped only once in an application.
    Other you Bind and Unbind as required N number of times.
    My Service is of second type. But just bind and unbind doesn’t do the job. The service first needs to be started then only it cna be bound and unbound. So on start of app or whereever appropriate, Start the service. Then Bind when required. When don with it, Unbind it. That Bind-Unbind circle can go on. And Finally when you are sure you don’t need it or at the end of the app Stop the Service. So the flow comes as
    Start -> Bind -> Unbind -> Stop
    <-

    Hope this helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An article has many articles that it refers to and many other articles can
I see many, many sites that have URLs for individual pages such as http://www.mysite.com/articles/this-is-article-1
In many database design tutorials/articles, they always bring up the fact that if two
Many articles (e.g. msdn ) have said that a circular reference cannot be cleaned
I read so many articles out there in the internet and found that to
I read books, articles, tutorials, and all that kind of stuff about the n-tier
I have read many MSDN articles about assembly signing and I haven't found nothing
I have read many articles about linq to sql performance. The result which i
There are many articles that described how to create a custom shaped window in
I tried to read many articles on dofactory , wikipedia and many sites. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.