我正在创建一个触发Intent的通知.这是我的代码的一个非常简短的摘录......
Notification notification = new Notification(R.drawable.icon, "notification", System.currentTimeMillis());
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(BackgroundService.this, ConnectionHandler.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.addFlags(Intent.FLAG_FROM_BACKGROUND);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, getString(R.string.notification_title), getString(R.string.notification_body), pendingIntent);
notification.flags |= notification.FLAG_AUTO_CANCEL;
nm.notify(1, notification);
Run Code Online (Sandbox Code Playgroud)
在我的意图(ConnectionHandler.class)中,我想展示一个有效的AlertDialog.但我希望在不打开新的UI窗口的情况下显示AlertDialog.对我来说最好的是,当点击通知条目时,AlertDialog只显示其他任何内容.
任何想法都表示赞赏.
此致,托比
我正在寻找一种方法来创建大型二进制文件的Delta Diff补丁(VMWare虚拟磁盘文件).是否有C#中的实现或.NET Framework中的任何有用方法.
任何帮助表示赞赏.谢谢.
rAyt
我构建了一个Testbox来了解Windows窗体应用程序中的线程.Silverlight和Java提供了Dispatcher,它在更新GUI元素时非常有用.
代码示例:声明类代表
public delegate void d_SingleString(string newText);
Run Code Online (Sandbox Code Playgroud)
创建线程
_thread_active = true;
Thread myThread = new Thread(delegate() { BackGroundThread(); });
myThread.Start();
Run Code Online (Sandbox Code Playgroud)
线程功能
private void BackGroundThread()
{
while (_thread_active)
{
MyCounter++;
UpdateTestBox(MyCounter.ToString());
Thread.Sleep(1000);
}
}
Run Code Online (Sandbox Code Playgroud)
委派TextBox更新
public void UpdateTestBox(string newText)
{
if (InvokeRequired)
{
BeginInvoke(new d_SingleString(UpdateTestBox), new object[] { newText });
return;
}
tb_output.Text = newText;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在BeginInvoke方法中声明Delate宣言?!
就像是
BeginInvoke(*DELEGATE DECLARATION HERE*, new object[] { newText });
Run Code Online (Sandbox Code Playgroud)
非常感谢,rAyt
作为编程的初学者,当我遇到墙壁时,它总是让我烦恼.目前,其中一面墙是共同依赖的物体.
正如你在我的问题历史中所看到的,我正在研究一个黑莓应用程序,我在其中实现了一些我称之为MVC模式的东西,但它并不是我认为它的意思.
你看,一个新手程序员,你看这个图形的摘要,你就会明白它背后的想法.但实施它是另一回事.
alt text http://www.ibm.com/developerworks/wireless/library/wi-arch6/theoretical.gif
请不要停止阅读:)我正在向你展示我的一些代码,其中包含一些黑莓特定的东西,但你应该看看我在做什么.
我的申请的主要入口点
public class ContactManager extends UiApplication
{
private static ContactManagerMainScreenModel MainScreenModel = new ContactManagerMainScreenModel();
private static ContactManagerMainScreen MainScreenView = null;
public static void main(String[] args)
{
new ContactManager().enterEventDispatcher();
}
public ContactManager()
{
MainScreenView = new ContactManagerMainScreen(MainScreenModel);
// Displays the Splashscreen then opens the Mainscreen
new SplashScreen(UiApplication.getUiApplication(), MainScreenView);
}
}
Run Code Online (Sandbox Code Playgroud)
主屏模型
public class ContactManagerMainScreenModel
{
ContactManagerMainScreen v;
// Loading Local Storage
LocalContactStorage LocalContactStorage = new LocalContactStorage();
// Define Data List
private Vector vContacts_Favorites;
public …Run Code Online (Sandbox Code Playgroud) 我正在运行J2ME应用程序并遇到一些严重的内存问题.
所以我构建了另一个步骤来清除巨大的输入字符串并处理其数据并清除它.但是,直到我开始并没有解决问题input = null,而不是input = "".
在内存管理方面不应该是一样的吗?有人可以解释一下我的区别吗?
谢谢,
rAyt
for(int x = 0; x <= ChunksPartCount; x++)
{
_model.setLoading_bar_progress((x * ChunkSize));
input += web_service.FullCompanyListChunksGet(x, ChunkSize);
if((x * ChunkSize) > 5000)
{
ReadXML(input);
input = null;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:
我仍然希望将答案标记为解决方案.我认为mmyers的言论正朝着正确的方向发展.
我目前正在测试最新的iOS4功能,以便将我的位置感知应用程序放在后台.嗯,确实有效!但另一方面,处理巨大的电力使用是非常讨厌的.
该应用程序在过去四个小时内消耗了大约50%的电池电量.它阅读了Apple关于此主题的完整官方文档,但我仍然不确定我的应用程序的哪些部分仍在运行以及哪些功能被暂停(在UI绘图旁边,应该很清楚).
我不使用任何真正的样板代码,而是像ASIHTTPRequest这样的扩展库与我的webservice交谈.使用朋友汽车进行的测试表明,当我使用ie时,网络连接和位置服务仍在运行
[locationManager startMonitoringSignificantLocationChanges];
Run Code Online (Sandbox Code Playgroud)
背景:应用程序在后台并执行代码[...]
我应该写一个"裸机"功能来接收和发送这个位置数据吗?我应该在应用程序驻留在后台的时间内删除所有其他对象以减少内存占用吗?似乎还没有任何最佳实践.
有任何想法吗?也许你们可以向我提供一些你的见解.谢谢.
编辑: 有一个名为能量诊断仪器的新仪器工具,用于记录连接设备的任何电源使用情况(适用于iPhone 3GS及更高版本).此外,设备应用程序 - >开发人员 - >电源使用中的设备上还有另一项服务.在现场测试您的用电量非常棒.创建的日志可以稍后在仪器中提取.
参考: WWDC 2010会议309 - 使用仪器进行高级性能分析
鉴于我目前的扩展方法:
public static List<char> rotate(this List<char> currentList, int periodes) {
if (periodes != 1) {
int x = currentList.Count() - 1;
return rotate(currentList.Skip(x).
Concat(currentList.Take(x)).ToList<char>(), periodes - 1);
}
return currentList;
}
Run Code Online (Sandbox Code Playgroud)
原始状态:
ring = new List<char>() { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
Run Code Online (Sandbox Code Playgroud)
目前的结果 ring.rotate(10);
J A B C D E F G H I
I J A B C D E F G H
H I J A B C D E F G …Run Code Online (Sandbox Code Playgroud) 在我的服务器上,我使用Python的标准示例(使用额外的Hello World方法),在客户端,我使用C#中的XML-RPC.NET库.但每次我运行我的客户端时,我都会得到一个例外,即找不到该方法.任何想法如何解决.
谢谢!
蟒蛇:
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)
# Create server
server = SimpleXMLRPCServer(("", 8000),
requestHandler=RequestHandler)
server.register_introspection_functions()
# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register_function(pow)
# Register a function under a different name
def adder_function(x,y):
return x + y
server.register_function(adder_function, 'add')
def HelloWorld():
return "Hello Henrik"
server.register_function(HelloWorld,'HelloWorld')
# Register an instance; all the …Run Code Online (Sandbox Code Playgroud) 所以,我开始构建一个小测试应用程序来测试lambda表达式.我在这里和其他地方找到了几个例子,但我没有得到它们.
有人可以通过使用文本框或任何其他变量来解释我如何构建表达式吗?
我的测试清单
List<People> lPeople = new List<People>
{
new People { Name= "Jean", LastName = "Borrow", Age= 21 } ,
new People { Name= "Dean", LastName = "Torrow", Age= 20 }
};
Run Code Online (Sandbox Code Playgroud)
工作lambda表达式
IEnumerable<People> result = lPeople.Where(p => p.Age < 21);
dgv_1.DataSource = result.ToList();
dgv_1.Update();
Run Code Online (Sandbox Code Playgroud)
如何动态构建表达式?
喜欢的东西lPeople.Where(p => p.LastName == Textbox.Text);(当然不起作用)
谢谢!
编辑:在下面的解决方案中添加了一些代码
Int32 iAge;
Boolean bSuc = Int32.TryParse(tb_filter_age.Text, out iAge);
if (!bSuc)
{
iAge = 0;
}
Run Code Online (Sandbox Code Playgroud) 我目前正忙着花些时间研究ASP.NET MVC.我正在做教程在ASP.NET MVC中创建一个电影数据库,它仍然使用ADO.NET Enity模型.我设法从LINQ实体模型创建一个列表视图.所以这是我的问题.绑定属性不适用于我的SQL实体.
Ado.NET的原始代码
public ActionResult Create([Bind(Exclude="Id")] Movie movieToCreate)
{
if (!ModelState.IsValid)
return View();
_db.AddToMovieSet(movieToCreate);
_db.SaveChanges();
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
我的LINQ代码
public ActionResult Create([Bind(Exclude = "Id")] Movies movieToCreate)
{
if (!ModelState.IsValid)
{
return View();
}
_db_linq.Movies.InsertOnSubmit(movieToCreate);
_db_linq.SubmitChanges();
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
但不排除Id字段.有任何想法吗?谢谢!