context.getClass和getPackageName的区别
来源:互联网 发布:什么叫还原网络设置 编辑:程序博客网 时间:2024/05/17 07:06
context.getClass和getPackageName的区别
一个是取得类名,一个是取得包名。
getClass 是java中Object类的成员函数,它的所有子类均可以用这个函数来取得当前类的类名;
getPackageName是Android中Context中用于得到包名的函数。
例子如下:
package com.my.test;
public class testActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mcontext = this.getApplicationContext();
Log.i(TAG, " class name: "+ getClass().toString());
Log.i(TAG," package name: " + getPackageName());
}
}
结果:
class name:com.my.test.testActivity
package name:com.my.test
0 0
- context.getClass和getPackageName的区别
- context.getClass和getPackageName的区别
- instanceof和getClass()的区别
- instanceof 和 getclass 的区别
- .class和.getClass()的区别
- getClass()和getSimpleName()的区别和作用
- getClass()和getSimpleName()的区别和作用
- getClass()和getSimpleName()的区别和作用
- getClass()和getSimpleName()的区别和作用
- getClass()和getSimpleName()的区别和作用
- getClass()和getSimpleName()的区别和作用
- 关于.getClass()和.class的区别
- java instanceof和getClass()的区别
- getClass(),forName()和.class的区别
- 关于.getClass()和.class的区别
- 关于.getClass()和.class的区别
- 关于.getClass()和.class的区别
- (十一)instanceof 和 getclass 的区别
- linux MISC 驱动模型分析
- HDU-1561 The more,The Better
- 欢迎使用CSDN-markdown编辑器
- Java NIO系列教程(五) 通道之间的数据传输
- 面试产品经理时如何回答“为什么想做产品经理”这个问题
- context.getClass和getPackageName的区别
- Andriod 中button监听事件的三种方式
- 矩阵、向量求导法则
- linux mysql 数据库开启外部访问设置指南
- 【挖坑】近期学习计划
- Android studio b Error: No resource found that matches the given name (at 'src' with value '@dra...
- Redis与Memcached的区别
- Incorrect line ending: found carriage return (\r) without corresponding newline (\n)
- Linux进程间通信