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

  • Home
  • SEARCH
  • 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 8905091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:18:15+00:00 2026-06-15T02:18:15+00:00

I have my service working, but for some reason it will not start my

  • 0

I have my service working, but for some reason it will not start my activity. It does not show an error in the logcat either. I want my service to start another activity. Is that possible? I checked to make sure my if statement was correct and it is. It does print out the HELLO.

service code below:

package com.example.textsmslock;
import java.util.Iterator;
import java.util.List;
import android.app.ActivityManager;
import android.app.Service;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.util.Log;
public class Logs extends Service
{
    @Override
    public IBinder onBind(Intent arg0){
         // TODO Auto-generated method stub
        return null;
    }
     @Override
        public void onStart(Intent intent, int startId) {
            // TODO Auto-generated method stub
            super.onStart(intent, startId);
            System.out.println("LOGS STARTED");
            ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
            List l = am.getRunningAppProcesses();
            Iterator i = l.iterator();
            PackageManager pm = this.getPackageManager();
            while(i.hasNext()) 
            {
                ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next());
                try 
                {
                    CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA));
                    Log.w("LABEL", c.toString());
                    //System.out.println("this is the charsequence: " + c);
                    //System.out.println("this is the log: " + Log.w("LABEL", c.toString()));
                    if(c.equals("Messaging"))
                    {
                        System.out.println("HELLO \n");

                        startActivity(new intent(("com.example.textsmslock.Enable"));

                    }
                }
                catch(Exception e) 
                {
                    //Name Not FOund Exception
                }
        }
       @Override
        public void onDestroy() {
            // TODO Auto-generated method stub
            super.onDestroy();
            System.out.println("LOGS STOPPED"); 
       }
}

android manifest

<activity
        android:name=".Enable"
        android:label="@string/title_activity_enable" >
        <intent-filter>
            <action android:name="com.example.textsmslock.Enable" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
<service android:name=".Logs" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </service>
  • 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-06-15T02:18:16+00:00Added an answer on June 15, 2026 at 2:18 am

    You have to add the flag Intent.FLAG_ACTIVITY_NEW_TASK to the activity intent.

    This line

    startActivity(new intent(("com.example.textsmslock.Enable"));
    

    Should now be

    Intent i = new Intent( this, YourActivity.class );
    i.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
    startActivity( i );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows Service that start some tasks based on a configuration. Each
I have a bunch of self-hosted WCF services. Everything's working fine but I'm look
I have web service urls that were working fine and are now returning the
I have a service, as follows: The most basic (working) CherryPy 3.1 Windows service
Im working on a Web-Application (MyWebApp). I have a Service-Reference to a WCF-Webservice. The
I have a working WCF service. I want to deploy it on Windows Azure.
I have modified a working Windows service that had always been starting beforehand. After
I have a Hessian service on Spring + iBatis working on Tomcat. I'm wondering
I have a WCF service application with most basic settings working properly on my
I have a WCF service as part of a client/server application I am working

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.