Android如果已注册启动服务活动,则启动注册活动(Android If registered launch service activity else launch registration activity)
我想知道如果用户已经注册了如何让我的应用程序启动服务活动?它没有登录活动而是注册活动。 因此,应用程序将从注册活动开始,注册后将进入服务活动。 当用户关闭应用程序时,如何使其从服务活动再次启动而不是从注册活动启动?
如何让它识别它是否已注册进入服务活动,如果它没有启动注册活动(登录数据将存储在共享偏好中我不知道如何做到这一点虽然如果它断开连接它将不得不重新连接)
我会感激任何答复,谢谢。
I was wondering how to make my app launch the service activity if the user is already registered?, it wont have login activity but registration activity. So the app will start with the registration activity, after registration it will go to the service activity. When user closes the app, how to make it launch again from the service activity and not from registration activity?
How to make it recognize if it is registered go to the service activity and if it is not launch the registration activity(login data will be stored in sharedpreferences I dont know any other way how to do it though in case it disconnects it will have to reconnect again)
I will appreciate any answer, Thanks.
原文:https://stackoverflow.com/questions/29584538
最满意答案
函数重载的事实并不真正相关。 这里真正的问题是函数指针和成员函数指针之间的区别。 我将在不重载的情况下运行一些示例。
解决方案:删除
static
,以便将它们定义为成员函数。 或者用'ns::ClassA::*ClassA_foo1
替换ns::ClassA::*ClassA_foo1
*ClassA_foo1
。 我想你想要后者。 (但我实际上建议你使用typedef
,正如其他人已经建议的那样)。考虑这两个:
namespace ns { struct ClassA { static ClassA foo(long); }; }
和
namespace ns { struct ClassA { ClassA foo(long); }; }
在前一种情况下,foo是
static
,因此是一个典型的函数,可以存储在函数指针中:ns::ClassA (ClassA_foo1)(long) = &ns::ClassA::foo;
如果你删除
static
,那么它不再是一个函数,它是一个成员函数。 指向成员函数的指针与指向函数的指针不同,它们必须使用一个对象来执行,该对象将是调用该方法的对象。函数指针的类型包括返回值的类型和参数的类型。 但是指向成员函数的指针类型还必须包含
this
对象的类型 - 您不希望能够在BankAccount
类型的对象上从Circle
运行方法。声明指向函数的指针:
ReturnType (*variable_name) (PARAM1, PARAM2)
声明指向成员函数的指针:
ReturnType (ThisObjectType::*variable_name) (PARAM1, PARAM2)
最后一行是有趣的。 乍一看,您可能认为
R (A::*v) (P1,P2)
声明了一个正常的函数指针,并将结果变量v
放入A
范围。 但事实并非如此。 相反,它定义了一个指向成员的指针函数,该函数对类型A
对象进行操作。The fact that the function is overloaded is not really relevant. The real issue here is the difference between a function-pointer and a member-function-pointer. I'll run through some examples without overloading.
Solution: Either remove the
static
, in order to define them as member-functions. Or else replacens::ClassA::*ClassA_foo1
with*ClassA_foo1
. I think you want the latter. (But I actually recommend you usetypedef
, as others have already suggested).Consider these two:
namespace ns { struct ClassA { static ClassA foo(long); }; }
and
namespace ns { struct ClassA { ClassA foo(long); }; }
In the former case, foo is
static
and is therefore a typical function, and can be stored in a function-pointer:ns::ClassA (ClassA_foo1)(long) = &ns::ClassA::foo;
If you remove the
static
, then it is not a function any more, it's a member function. And pointers-to-member-functions are different from pointers-to-functions, they must be executed with an object that will be thethis
object on which the method is called.The type of a function pointer includes the type of the return value and the type of the parameters. But the type of a pointer-to-member-function must also include the type of the
this
object - you wouldn't expect to be able to run a method from aCircle
on an object of typeBankAccount
.Declaring a pointer-to-function:
ReturnType (*variable_name) (PARAM1, PARAM2)
Declaring a pointer-to-member-function:
ReturnType (ThisObjectType::*variable_name) (PARAM1, PARAM2)
This last line is the interesting one. At first glance, you might think that
R (A::*v) (P1,P2)
declares a normal function-pointer and places the resulting variablev
into theA
scope. But it does not. Instead it defines a pointer-to-member-function which operates on objects of typeA
.
相关问答
更多-
是的,您可以通过这种方式调用静态函数 Yes, you can call static function in that way
-
DialogProc函数要求声明它自身静态[重复](DialogProc function asking to declare it self static [duplicate])[2023-10-17]
如果通过 静态DialogProc中的全局声明变量 你的意思是AMEPreviewHandler实例中的成员变量,我想你已经在LPARAM中发送了你需要的东西: m_hwndPreview = CreateDialogParam( ...(LPARAM)this); 当它调用你的DialogProc时,这些转到最后一个参数: LPARAM lParam所以你可以这样做 AMEPreviewHandler* instance = (AMEPreviewHandler *)lParam; instance-> ... -
使用函数参数[重复]对重载函数进行奇怪的模糊调用(Wierd ambiguious call on overloaded function with a function parameter [duplicate])[2023-12-03]
Tim引用的Eric Lippert在帖子中的重要内容是: 这里的原则是确定方法组可转换性需要使用重载决策从方法组中选择方法,并且重载决策不考虑返回类型。 在您的代码中,方法组转换在行动中并导致问题。 建议的解决方案消除了问题。 The important thing in the post by Eric Lippert cited by Tim is: The principle here is that determining method group convertibility requires ... -
函数重载的事实并不真正相关。 这里真正的问题是函数指针和成员函数指针之间的区别。 我将在不重载的情况下运行一些示例。 解决方案:删除static ,以便将它们定义为成员函数。 或者用' ns::ClassA::*ClassA_foo1替换ns::ClassA::*ClassA_foo1 *ClassA_foo1 。 我想你想要后者。 (但我实际上建议你使用typedef ,正如其他人已经建议的那样)。 考虑这两个: namespace ns { struct ClassA { static Clas ...
-
您需要自己将它们放入范围: class C : public A, public B { public: using A::fun; using B::fun; }; You need to put them into scope yourself: class C : public A, public B { public: using A::fun; using B::fun; };
-
static表示该函数具有内部链接。 这意味着它不会与其他文件(翻译单元)中相同标识符的其他用途链接。 例如,假设在Tree.c我有一个在Tree结构上运行的函数,我有一些名为UpdateNode本地子程序,它在Tree的一部分上运行。 进一步假设在List.c ,我有一个对List结构进行操作的函数,它还有一些名为UpdateNode本地子例程,它只适用于List结构,而不适用于Tree结构。 如果我将这两个子例程都与外部链接一起离开,那么链接器会抱怨多个定义。 通过用static内部连接标记它们,避免了 ...
-
首先,您需要将A声明为完整类型(例如, A
)。 检查一个对象是否可调用是不可靠的,只需通过展开和比较它的operator() 因为它将在模板化或重载的函子上失败 。 我使用以下代码来检测对象是否可以使用给定的函数签名进行调用( ReturnType(Arguments...) ) 这也适用于重载或模板的operator() ,因为代码试图用给定的参数调用对象,而不是比较它的解包operator()的签名。 除此之外,还可以检查对象是否可以从const,volatile或rvalue上下文中调用。 ... -
SFINAE仅在重载解析期间应用,如果没有函数调用,则不存在重载解析。 SFINAE applies only during overload resolution, and if there is no function call, there is no overload resolution.
-
看来,在A:: someStaticMethod的上下文中,PHP允许您直接访问私有变量$test ,因此魔术方法不会执行。 如果你echo $a->test; 从那里,你会看到它被访问。 根据PHP手册 ,这是预期的行为: 相同类型的对象可以访问彼此私有和受保护的成员,即使它们不是相同的实例。 这是因为在这些对象内部时已经知道实现特定的细节。 It seems that, in the context of A:: someStaticMethod, PHP allows you to access th ...
-
相关文章
更多- 不能通过finishAcitivity从当前activity关闭另一个activity吗?
- android 使用Activity做窗口弹出(模拟Dialog)
- android仿微信的activity平滑水平切换动画
- 《发布Joomla! 网站到互联网:宁皓网》(Launch your Joomla! site to the internet @ ninghao.org)开放式课程[MOV]
- Android 模仿微信启动动画
- 使用init.rc启动项调试service
- android布局问题
- 关于Service常驻内存不被清理的解决方法.
- Web Service PHP入门示例
- RFC2848--The PINT Service Protocol: Extensions to SIP and SDP for IP Access to Telephone Call Services
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。