小编nic*_*ico的帖子

Android:无法启动服务意图:找不到?

我知道,我不是第一个遇到这个问题的人,但我尝试了很多解决方案,我发现并且没有人工作......也许你会发现错误

错误(也是如此,没有.class和/.Client取决于其他设置)

12-02 16:40:15.359:W/ActivityManager(74):无法启动服务Intent {act = com.android.fh.EnOceanApp.Client.class}:未找到

在清单中,这包含在应用程序中,不在活动中(在活动中也尝试使用".Client")

onCreate()中的代码

    startService(new Intent(this, Client.class)); 
Run Code Online (Sandbox Code Playgroud)

要么

 startService(new Intent(this.getApplicationContext(), Client.class));
Run Code Online (Sandbox Code Playgroud)

要么

Intent intent=new Intent("com.android.fh.EnOceanApp.Client.class");
    this.startService(intent);
Run Code Online (Sandbox Code Playgroud)

要么

  Intent intent=new Intent("com.android.fh.EnOceanApp.Client");
    this.startService(intent);
Run Code Online (Sandbox Code Playgroud)

现在,我再也没有一个想法.... com.android.fh.EnOceanApp是包,Client.java是这个包中的服务类

我忘记了清单:

  <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".EnOceanAppActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

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

      <activity android:name=".ListView" 
          android:label="List View">
      </activity> 
      <activity android:name=".GraphView" 
          android:label="Graph View">
      </activity>
      <service 
            android:name=".Client"></service> //with and without ., of course without this comment
    </application>
Run Code Online (Sandbox Code Playgroud)

java service android classnotfound

16
推荐指数
2
解决办法
4万
查看次数

如何停止计时器触发的runloop?

如果我设置这样的runloop:

NSRunloop* loop = [NSRunloop currentRunLoop];
[runLoop addTimer:anyTimer forMode:NSDefaultRunLoopMode];
Run Code Online (Sandbox Code Playgroud)

我可以再次阻止它吗?或者是忽略我用来触发进一步行动的通知的唯一方法?

好的,我举一个问题的例子:

-(void)blinkeffekt:(double)pollingTime{

NSRunLoop* runLoop = [NSRunLoop currentRunLoop];

if (pollingTime != 0) {
    NSTimeInterval interval =(double)pollingTime / 1000;
    NSTimer timer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(polling) userInfo:nil repeats:YES];
    [runLoop addTimer:timer forMode:NSDefaultRunLoopMode];
}
else {

    [timer invalidate];
}
Run Code Online (Sandbox Code Playgroud)

}

当然,这里有几个错误 - 毫无疑问.但我想,它显示了我的问题.直到现在,这个答案还无法解决.

我需要运行一个计时器并在以后停止它.理想情况下,在课堂上的另一个功能.但后来我不能访问"定时器"了,并runloop犯规让搞清楚,如果这样的"消息"是可用的.如果我为每个函数调用注册一个新的计时器,它将是非常无效的.

iphone timer objective-c nsrunloop

9
推荐指数
1
解决办法
1万
查看次数

复制了来自apple的reachability-test,但链接器失败了

我试图使用apple发布的reachability-project来检测自己的例子中的可达性.我复制了最多的初始化,但是我在链接器中遇到了这个失败:

Ld build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test normal armv6
cd /Users/uid04100/Documents/TEST
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1.3
setenv PATH  "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -L/Users/uid04100/Documents/TEST/build/Debug-iphoneos -F/Users/uid04100/Documents/TEST/build/Debug-iphoneos -filelist /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test.LinkFileList -dead_strip -miphoneos-version-min=3.1.3 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test
Run Code Online (Sandbox Code Playgroud)

未定义的符号:
"_SCNetworkReachabilitySetCallback",引自: - Reachability.o中的[ - Reachability startNotifer]
"_SCNetworkReachabilityCreateWithAddress",引自:Reachability.o中的:[Reachability reachabilityScheduseWithRunLoop]
,引用自: - [Reachability startNotifer] .o
"_SCNetworkReachabilityGetFlags",引自: - Reachability.o中的[Reachability connectionRequired] - Reachability.o中的[Reachability currentReachabilityStatus]
"_SCNetworkReachabilityUnscheduleFromRunLoop",引自: - Reachability.o中的[Reachability stopNotifer]
"_SCNetworkReachabilityCreateWithName",引用自: + Reachability.o中的[Reachability reachabilityWithHostName:]
ld:找不到符号
collect2:ld返回1退出状态

我的代表团:

#import <UIKit/UIKit.h>

@class Reachability;

@interface testAppDelegate : NSObject
<UIApplicationDelegate> {  UIWindow
*window;  UINavigationController *navigationController;

 Reachability* hostReach; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa reachability

7
推荐指数
1
解决办法
4959
查看次数

按下时切换UIButton状态,如开关

-(void)setState:(id)sender
{
    UIButton* button = (UIButton*)sender;
    BOOL buttonBool = ([button state]==selected : YES ? NO);
    [sender setSelected:buttonBool++];

}
Run Code Online (Sandbox Code Playgroud)

这是我的想法,但我无法弄清楚调用funktion按钮的实际状态.任何调用此功能的按钮都应该在默认状态和选择状态之间切换,以便它像交换机一样工作.我只需要拥有自己的背景图形,否则我使用了一个开关.

那么,任何人都可以纠正我的想法吗?

iphone objective-c uibutton togglebutton

7
推荐指数
1
解决办法
1万
查看次数